RE: Folding a bitfield in a union

2014-06-29 Thread Thomas Preud'homme
> From: Richard Biener [mailto:richard.guent...@gmail.com] > Sent: Friday, June 27, 2014 6:23 PM > > Yes - I was specifically looking for an early out to avoid wrong-code. > So, is size % BITS_PER_UNIT != 0 a working fix to avoid the wrong-code > issues with bitfields (on big-endian targets)? I'm

Re: Folding a bitfield in a union

2014-06-27 Thread Richard Biener
On Fri, Jun 27, 2014 at 12:02 PM, Thomas Preud'homme wrote: >> From: Richard Biener [mailto:richard.guent...@gmail.com] >> Sent: Friday, June 27, 2014 5:32 PM >> > 4) Cast value stored in a according to the size of b by removing bits of >> > highest weight (via VIEW_CONVERT_EXPR). >> >> Fact is th

RE: Folding a bitfield in a union

2014-06-27 Thread Thomas Preud'homme
> From: Richard Biener [mailto:richard.guent...@gmail.com] > Sent: Friday, June 27, 2014 5:32 PM > > 4) Cast value stored in a according to the size of b by removing bits of > > highest weight (via VIEW_CONVERT_EXPR). > > Fact is that 4) already is not working. > > /* We are at the end of walk,

Re: Folding a bitfield in a union

2014-06-27 Thread Richard Biener
On Fri, Jun 27, 2014 at 8:51 AM, Thomas Preud'homme wrote: > Greetings everybody, > > I'm seeking your advice on how to best solve a bug. The issue has to do with > folding a bitfield contained in a union. Consider the following example: > > union U { > unsigned int a:24; > unsigned int b:20;

Folding a bitfield in a union

2014-06-26 Thread Thomas Preud'homme
Greetings everybody, I'm seeking your advice on how to best solve a bug. The issue has to do with folding a bitfield contained in a union. Consider the following example: union U { unsigned int a:24; unsigned int b:20; } u = { .a = 0x345678 }; int foo (void) { return u.b; } Currently, fo