bugTiny C Compiler - Bugs: bug #51169, tcc miscompiles unsigned long long...

 
 

bug #51169: tcc miscompiles unsigned long long bitfields

Submitted by:  Tony Garnock-Jones <surazal>
Submitted on:  Sat 03 Jun 2017 03:04:50 PM UTC  
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  None
Privacy:  Public Assigned to:  None
Open/Closed:  Open

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Sat 03 Jun 2017 05:00:50 PM UTC, comment #1:

Could the following patch be a step toward a fix? (Also attached)

Tony Garnock-Jones <surazal>
Sat 03 Jun 2017 03:04:50 PM UTC, original submission:

This is using tcc:i386 on Debian,
tcc version 0.9.27 (prerelease) (i386 Linux)

The following program should produce exit status 0, but produces exit status 1.

The problem is that it is using SAR instead of SHR to extract the bit field in the switch.

struct foo {
unsigned long long t: 4;
unsigned long long s: 60;
};

void init_foo(struct foo *f) {
f->t = 8;
f->s = 0;
}

int main(int argc, char *argv[]) {
struct foo f;
init_foo(&f);
switch (f.t) {
case 8:
return 0;
default:
return 1;
}
}

Tony Garnock-Jones <surazal>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #40848:  t.c added by surazal (277B - text/x-csrc)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by surazal (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

     

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-06-03 surazal Attached File- => Added experimental-bug51169.patch, #40849
    2017-06-03 surazal Attached File- => Added t.c, #40848

    Back to the top


    Powered by Savane 3.4