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]

Darwin gcc 3.3 sizeof of C++ structures with long long ints is strange


Kevin B. Hendricks writes:
 > 
 > I am exploring the use of gcc 3.3 (based on CVS from yesterday) to build 
 > OpenOffice.org under MacOSX/Darwin (we have had troubles with Apple's gcc 
 > 3.1 that don't seem to happen under gcc 3.3)?
 > 
 > Unfortunately, the following structure alignment program shows the size of 
 > structure C5 is 4 bytes larger than expected. 
 > 
 > If you look at the code the key issue is that C5 uses a long long int type.  
 > If I replace the long long int with a double (both are 8 bytes in size) 
 > the expected size is achieved.
 > 
 > Will someone familar with C++ structure alignment and Darwin please take a 
 > look at this testcase for me?
 > 
 > Is there something funny happening with long long ints here?

You may be aware that the way C++ structs are laid out in memory has
changed as a result of the multivendor C++ ABI.

It looks to me like sizeof(C5) is rounded up to a multiple of C5's
alignment.  This is not very strange.  If you don't want this to
happen, you can use __attribute__ ((packed)).

Andrew.



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