This is the mail archive of the 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: Size difference in base class between GCC releases

On 27 August 2012 19:48, Paul_Koningwrote:
> I'm doing some checking of data structure layouts in different releases of our code -- which were produced by different releases of GCC (3.3.3 vs. 4.5.4).
> One difference I'm seeing that is puzzling is in the handling of base classes.  Specifically, the case where a base class has padding at the end to fill it out to a multiple of the alignment.
> In GCC 3.3.3, when such a class is used as a base class, that padding is omitted, and the first derived class data member starts right after the last base class real (not pad) data member.  In GCC 4.5.4, the base class is used padding and all, the first derived class data member starts after the padding of the base class.

This depends on whether the base class is a POD or not.

According to a note in the Itanium C++ ABI "the C++ standard requires
that compilers not overlay the tail padding in a POD" (I don't know
off the top of my head where that is stated in the standard.)

> Which is correct?  Or are both correct?  This sort of thing is a potential cause of trouble if such a class is used as a container for persistent data.

GCC 3.4 and later conform to the Itanium C++ ABI, which specifies the
behaviour you're seeing as required by the C++ standard, so 4.5 is

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