This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Missed bitfield packing?


Adam Nemet <anemet@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 fields whose type has alignment <= BITS_PER_UNIT:

This was introduced for PR 21166.  I think you're right that the
alignment check should be ignored if the bitfield is a bitfield.

Ian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]