DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
Robert Dewar
dewar@gnat.com
Thu Apr 17 10:44:00 GMT 2003
> What I don't get is why such cases must be distinguished. I mean, if
> an alignment is specified by the user for a type, is it not true that
> the user is also specifying the alignment for any objects of that
> type, except when overridden for a specific object? It seems to me
> that this is the point of the change that propagates TYPE_USER_ALIGN
> to DECL_USER_ALIGN, and I can't see how this could possibly be
> incorrect. I mean, if it is not, then, given:
Yes, you are specifying an alignment for objects of the type, but the
implementation is always free to give a larger alignment. Consider in
Ada
type r is new string (1 .. 1000);
for r'alignment use 1; -- that's also the default if not specified
a,b : r;
a compiler may well decide to give larger alignment for a and b to improve
the efficiency of the code (e.g. for the assignment a := b).
An alignment specifies the minimum alignment that is guaranteed and that
can be assumed of all objects. It is just fine for a compiler to increase
the alignment to improve the code provided that does not violate other
specifications (e.g. a record that is layed out that contains components
of the type).
More information about the Gcc
mailing list