[cxx-abi-dev] Question about tail padding

Nathan Sidwell nathan at codesourcery.com
Thu Aug 15 16:39:12 UTC 2002


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).

nathan

-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan at codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan at acm.org



More information about the cxx-abi-dev mailing list