This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Darwin gcc 3.3 sizeof of C++ structures with long long ints is strange
- From: Andrew Haley <aph at redhat dot com>
- To: "Kevin B. Hendricks" <kevin dot hendricks at sympatico dot ca>
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 19 Mar 2003 10:20:28 +0000 (GMT)
- Subject: Darwin gcc 3.3 sizeof of C++ structures with long long ints is strange
- References: <200302071117.50348.kevin.hendricks@sympatico.ca>
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.