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


WHat I still cannot understand is why a struct that contains a double
is 4-aligned on x86, but a double is 8-aligned.  This means that you
cannot infer the alignment of a struct from the alignment of its
members.  Is this really part of the multi-vendor ABI?

Andrew.


#include <stdio.h>

int
main (int argc, char **argv)
{
  typedef struct foo { double x; } foo;
  foo bar;
  printf ("double align %d size %d\n", __alignof__(double), sizeof(double));
  printf ("foo align %d size %d\n", __alignof__(foo), sizeof(foo));
  
  return 0;
}


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