[C++ PATCH] ctor vtable vcall offsets

Mark Mitchell mark@codesourcery.com
Tue Feb 27 10:16:00 GMT 2001


>>>>> "Jason" == Jason Merrill <jason@redhat.com> writes:

    Jason> Actually, I don't see why we ever need to emit thunks with
    Jason> the vtable.  The example in the ABI document is

    Jason>   struct A { virtual void f(); }; struct B : virtual public
    Jason> A { int i; }; struct C : virtual public A { int j; };
    Jason> struct D : public B, public C {};

    Jason> But here, calling A::f() means converting to A* then
    Jason> calling through the A vtable, so the entry in the C vtable
    Jason> is never used.

    Jason> What am I missing?

I thought the intent was to avoid having to do that conversion.  

At the time you do the conversion, you don't know where the override
will be; in many cases it will be wasted work.

So, I thought the intent was to make sure that the entry in C's vtable
(which contains an entry for `f' since A is the primary base) is
valid.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com



More information about the Gcc-patches mailing list