On Aug 27, 2012, at 3:33 PM, Jonathan Wakely wrote: > 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 > correct.
Interesting. What if the base class is not a POD? It doesn't seem to be, if I remember the definition of POD correctly. paul