This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: [C++ PATCH] ctor vtable vcall offsets


>>>>> "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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]