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: Darwin gcc 3.3 sizeof of C++ structures with long long ints is strange


Hi,

This alignment issue does not exist in Apple's gcc 3.1 using 
-malign-natural  and does not exist in Apple's gcc 2.95 version either.

I talked to Geoff Keating about ti and he felt that the alignment 
constraint of long long ints and the comment found in the gnu gcc 3.3 code 
was wrong ands that long long ints should NOT have higher alignment 
constraints than doubles.

So the problem is you are not aligning it to max 4 purely (long long ints 
are the exception) nor are you using natural alignment (8 for double and 
long long int).

So you ar enot abi compatible with anyone (apple's gcc versions included).

I have simply changed this in my own gcc 3.3 builds for Apple. Geoff was 
actually looking for a volunteer to somehow rationalize the gnu gcc long 
long int alignment for darwin with Apple's alignments.

Kevin


On March 19, 2003 05:20 am, Andrew Haley wrote:
> 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]