Re: Missed bitfield packing?

2009-01-16 Thread Ian Lance Taylor
Adam Nemet ane...@caviumnetworks.com writes: struct s { char a:4; char b:8; char c:4; } __attribute__ ((packed)) is 3 bytes long because b gets pushed to the next byte boundary. Sounds like a bug. The reason for this behavior is that finish_struct does not propagate packed to

Re: Missed bitfield packing?

2009-01-16 Thread Richard Guenther
On Fri, Jan 16, 2009 at 4:19 PM, Ian Lance Taylor i...@google.com wrote: Adam Nemet ane...@caviumnetworks.com writes: struct s { char a:4; char b:8; char c:4; } __attribute__ ((packed)) is 3 bytes long because b gets pushed to the next byte boundary. Sounds like a bug. The

Missed bitfield packing?

2009-01-15 Thread Adam Nemet
struct s { char a:4; char b:8; char c:4; } __attribute__ ((packed)) is 3 bytes long because b gets pushed to the next byte boundary. You would think that similarly: struct t { char a:4; short b:16; char c:4; } __attribute__ ((packed)) would come out to be 4 bytes long. However,