What thunks are needed?

Jason Merrill jason_merrill at redhat.com
Wed Jun 6 11:43:21 UTC 2001


Consider:

       class A { virtual void f (); };
       class B1 : virtual public A { virtual void f (); };
       class B2 : virtual public A { virtual void f (); };
       class C: public B1, public B2 { virtual void f (); };

The ABI spec currently says that we need a thunk for every base, period.
Clearly this is wrong; we only need thunks for bases which define the
function (i.e. vtables for them to go in).  Furthermore, we only need one
thunk per adjustment, since that's what is mangled.  Nor do we need thunks
that adjust by 0; we can just point to the function itself.  I'll write up
a patch for these soon.

So: For C::f, we need a virtual thunk for A, no thunk for B1, and a 
non-virtual thunk for B2.  But it occurs to me that since the B2 vtable
already has a vcall slot for f, we can use the virtual thunk there, too,
so we only really need one thunk.

Thoughts?  The current g++ implementation doesn't generate the non-virtual
thunk, so this change would actually improve compatibility between a
compliant compiler and the current one.  What do other implementations
currently do for this testcase?

Jason




More information about the cxx-abi-dev mailing list