[cxx-abi-dev] Question about tail padding
scott douglass
sdouglass at arm.com
Fri Aug 16 11:00:54 UTC 2002
At 05:39 PM 15-08-02 +0100, you wrote:
>mendell at ca.ibm.com wrote:
>>
>> With allocation of derived classes in tail padding, what happens in the
>> following case
>>
>> struct S1 {
>> virtual void f();
>> int i;
>> char c1;
>> }; // sizeof (S1) == 16 in 64 bit mode
>>
>> struct S2 : public S1 {
>> char c2; // allocated next to c1
>> }; // sizeof (S2) == 16 in 64 bit mode
>>
>> S2 s2;
>> S1& rs1 = &s2;
>> S1 s1;
>>
>> rs1 = s1; // this will clobber the char member of s2.
>>
>> Is this a reasonable interpretation? Doesn't the assignment of S1s copy
>> the tail padding?
>No. You must arrange that S1::operator= does not copy tail padding.
>(S1 is non-pod, pods are different).
If the tail padding must not be changed this will be quite inefficient when there is a trailing bit-field -- it makes you wish there were separate whole-object op= and a sub-object op=.
More information about the cxx-abi-dev
mailing list