Why don't we just FIX the damn vthunk problem?
Martin v. Loewis
martin@mira.isdn.cs.tu-berlin.de
Wed Mar 3 00:45:00 GMT 1999
> Oops, no, I was misreading the code in emit_base_init. We set the vptrs
> after the base ctors but before the member ctors. So I once again believe
> that passing via the vptr will work; each ctor would do something like
>
> vtable *tmp = (vtable *) this->A::vptr;
> Base::Base(this, 0);
> this->A::vptr = tmp[1];
It'll work if it is used consistently throughout the hierarchy. If the
derived class is not recompiled, it does
if (in_chrg)
A::A(); // now this->A::_vptr is initialized
Base::Base(this,0);
this->A::_vptr = __vt_of_most_derived_class
The recompiled base class would find a vtbl in A::_vptr, not a
vtable*. It would then initialize this->A::vptr with a function
pointer, or crash if tmp[n] is out of range. It'll definitely crash if
the base class constructor does call a virtual function.
Regards,
Martin
More information about the Gcc
mailing list