This is the mail archive of the
mailing list for the GCC project.
Re: Size difference in base class between GCC releases
On Mon, Aug 27, 2012 at 3:16 PM, <Paul_Koning@dell.com> wrote:
> On Aug 27, 2012, at 4:05 PM, Gabriel Dos Reis wrote:
>> On Mon, Aug 27, 2012 at 1:48 PM, <Paul_Koning@dell.com> wrote:
>>> 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.
>>> 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.
>> Is this message
>> relevant to your case?
>> -- Gaby
> Yes, that looks like the exact case. And the mail thread seems to say that the "3.3.3" behavior I'm seeing is what G++ was doing at that time, as was HP -- but not Intel. So now we have it done differently in later compilers.
> I know this is changing data structure layouts in our code; I don't know yet if that is a problem (i.e., if it applies to layouts used in persistent data or in protocol messages). I assume there isn't some compiler switch I can use to control this behavior?
Normally, any changes like this is controlled by -fabi-version; you
can also get warnings
with -Wabi. See the discussion at
if it is of any help.