This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
- From: dewar at gnat dot com (Robert Dewar)
- To: aoliva at redhat dot com, kenner at vlsi1 dot ultra dot nyu dot edu
- Cc: gcc-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org, rth at redhat dot com
- Date: Thu, 17 Apr 2003 04:52:00 -0400 (EDT)
- Subject: Re: DATA_ALIGNMENT vs. DECL_USER_ALIGNMENT
> 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).