Re: arm-none-eabi-gcc: packed attribute causes inefficient alignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 17 Aug 2023, Tony Josi via Gcc-help wrote:

> I would also like to understand the reasoning behind this warning. When a
> struct is packed explicitly it's expected that the padding required for the
> alignment of the fields will be removed and it might cause inefficient data
> access.
> It makes sense to warn when a packed attribute has no effect on struct
> layout but I fail to understand why specific fields that are already
> aligned in a struct are warned when the whole struct is packed.

No, 'ch1' in your example does not keep the original 32b alignment:
the attribute reduces the size of the struct from 12 to 10 bytes, so
it can no longer be 4-byte aligned. Worse, the attribute is documented
to reduce struct alignment down to one byte, and 'ch1' has the same
alignment as the whole struct.

Alexander



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux