vtable layout

Jason Merrill jason at cygnus.com
Sat Aug 28 06:01:39 UTC 1999


>>>>> thomson  <thomson at ca.ibm.com> writes:

 > For the hierarchy

 > struct A { virtual void f(); };
 > struct B : A { void f(); };
 > struct C : A { void f(); };
 > struct other { virtual void g(); }
 > struct D : other, B, C { void f(); }

 > where do you put the convert-B-to-D and convert-C-to-D slots, such that
 > D::f()'s secondary entry finds the right one?

 > You need to locate them so that the address differences

 >    &cvt-B-to-D - &B-in-D-vtable
 >    &cvt-C-to-D - &C-in-D-vtable

 > are equal

I don't see why.  The D::C and D::B vtables can refer to different entry
points, so they can look in different places to find the 'this'
adjustment.

This does defeat my earlier claim that we would need at most two entry
points for virtual functions that don't use covariant returns.  Rather, we
get one per vtable where the function appears.

Jason




More information about the cxx-abi-dev mailing list