On alignment

Andrew Haley aph@redhat.com
Tue Apr 22 15:13:00 GMT 2003


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++.  Look at this:


#include <stdio.h>

int
main (int argc, char **argv)
{
  struct { int n; double x; } baz;
  const double &a = baz.x;
  printf ("baz.x align %d\n", __alignof__ baz.x);
  printf ("a align %d\n", __alignof__ a);
  
  return 0;
}


baz.x align 4
a align 8


Andrew.



More information about the Gcc mailing list