Construction vtables
Mark Mitchell
mark at codesourcery.com
Wed Jun 28 01:38:38 UTC 2000
Folks --
The construction vtable group does not contain unncessary secondary
vtables:
The construction vtable group for a proper base class subobject B (of
derived class D) does not have the same entries in the same order as
the main vtable group for a complete object B, as described in Virtual
Table Layout above. Some of the base class subobjects may not need
construction vtables, which will therefore not be present in the
construction vtable group, even though the subobject vtables are
present in the main vtable group for the complete object.
I thought that one of the advantages to forming vtable groups (rather
than having separate secondary vtables) was so that give a pointer to
a derived class vtable you could find a non-virtual base class vtable
without actually converting to the base. You just look at a fixed
offset from the derived class vtable. For example, given:
struct B1 { virtual void f(); };
struct B2 { virtual void g(); };
struct D : public B1, B2 {};
D* d = new D;
d->f ();
d->g ();
You can generate code like:
b1_in_d_vptr = *((ptrdiff_t**) d);
(*b1_in_d_vptr[0]) ();
(*b1_in_d_vptr[<constant>]) ();
But, that means this trick doesn't work during object construction,
which seems bad.
What am I missing?
--
Mark Mitchell mark at codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
More information about the cxx-abi-dev
mailing list