DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT

Geert Bosch bosch@gnat.com
Thu Apr 24 05:47:00 GMT 2003


On Wednesday, Apr 23, 2003, at 23:30 America/New_York, Jason Merrill 
wrote:
> It also sounds like in Ada, specifying an alignment for a type means 
> "don't
> reduce", but specifying it for an object means both "don't reduce" and
> "don't increase".  It seems to me that the way to handle this is to set
> DECL_PACKED on such objects.

No, this is not the case. Specifying an alignment for an object means
"don't reduce". Of course the compiler should have a good reason to
increase, but that's a quality of implementation issue. For example,
a compiler might well align all 14-byte local objects of a 2-byte
aligned type to 16 bytes and then take advantage of that stricter
alignment in code generation.

Specifying an alignment for a type means "don't reduce" the alignment
for any allocations of objects of this type and "don't assume increased"
alignment for any objects accessed of this type.

   -Geert



More information about the Gcc-patches mailing list