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: On alignment


Jason Merrill writes:
 > On Tue, 22 Apr 2003 13:37:43 +0100, Andrew Haley <aph at redhat dot com> wrote:
 > 
 > > Robert Dewar writes:
 > >  > > That packing rule is part of the i86 psABI
 > >  > 
 > >  > It's still mighty odd, and of course in Ada you have to override this rule
 > >  > since it conflicts with the Ada standard, which requires that the default
 > >  > minimum alignment of a composite be not less than the alignment of any
 > >  > component.
 > >
 > > It's pretty weird in C++.
 > 
 > It's the same in C.  Weird or not, that's what the SVR4 psABI says, so
 > that's what we do.

It's rather scary.  It means, for example, that

template<class T> void copy (T *a, T *b)
{
  if (__alignof__ (T) >= 8)
    copy_by_dwords (a, b);
  else
    copy_by_bytes (a, b);
}    

won't do what is expected when applied to a member of a struct.  I
suppose we get away with this because the x86 never generates
alignment traps in such cases.

Andrew.


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