Vcall/vbase offset clarification
Jim Dehnert
dehnert at baalbek.engr.sgi.com
Fri Feb 4 22:28:35 UTC 2000
> From: Martin von Loewis <loewis at informatik.hu-berlin.de>
> To: mark at codesourcery.com
>
> > > From mitchell at codesourcery.com Tue Jan 25 13:26:12 2000
> > > struct A { void f();}
> > > struct B : public virtual A {};
> [...]
> > > o First, we convert to the most derived class in which `f' was
> > > overridden. That's `A'. We know statically what offset
> > > to adjust `b' by to get an `A*'.
>
> Maybe you didn't mean it that way, but: How do we know statically the
> offset needed to adjust a B* to an A*? Wouldn't we have to look in the
> vtable at run time to fetch the vbase offset?
>
> > > o We pass this value to the function found in the vtable for `A'.
> > >
> > > o That function will first perform the constant adjustment from
> > > `A' to `B'.
>
> Or perhaps that shouldn't have been virtual inheritance in the B
> bases?
I think the right statement is 'we know statically how to adjust "b" to
get an "A*". If A is a non-virtual base, we know the offset
statically. If it is a virtual base, we know statically where to fetch
the vbase offset in the vtable.'
Jim
- Jim Dehnert dehnert at sgi.com
(650)933-4272
More information about the cxx-abi-dev
mailing list