On 27 August 2012 21:16, Paul Koning wrote:
>
> On Aug 27, 2012, at 4:05 PM, Gabriel Dos Reis wrote:
>>
>> Is this message
>>
>> http://gcc.gnu.org/ml/gcc/2002-08/msg00874.html
>>
>> 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.
That mail is talking about reusing tail padding in non-PODs, and G++
still does that, i.e. this code compiles:
struct S1 {
virtual void f();
int i;
char c1;
};
struct S2 : public S1 {
char c2;
};
const S2 s2{};
static_assert( (&s2.c2 - &s2.c1) == 1, "Reused tail padding" );
Please check whether the code you're looking at involves a POD base
class, because that would explain why G++ 4.5 doesn't reuse the tail
padding (I have no idea if 3.3 does or doesn't, but using
-fabi-version=1 to request the G++ 3.2 ABI doesn't seem to cause tail
padding in PODs to be reused.)