Vcall/vbase offset clarification

Mark Mitchell mark at codesourcery.com
Tue Jan 25 18:38:13 UTC 2000


It is unclear from the draft what sign these offsets should have.  (In
other words, to compute the address of the vbase, do we add the vbase
offset, or subtract it?  To compute the adjusted `this' pointer do we
add the offset, or subtract it?)

I expect the intention was to make these additive, but we should add
some explicit language.  How about:

  The vbase offset is the value that must be added to the address of
  the derived class in order to obtain the address of the virtual 
  base.

  The vcall offset is the value that must be added to the `this' 
  pointer in the most-derived class in order to obtain the correct
  `this' pointer for the function called.

Also, it is probably worth noting in the Category 3/Category 4 section
on class layout that the algorithm for calculating what vbase offsets
you need is actually uniform.  The complication in Category 4 about
whether an indirect virtual base is inherited directly via a
non-virtual base cannot arise in Category 3 -- but it is correct to
simply code the Category 4 algorithm and apply it everywhere.  

In other words, the Category 3 algorithm is merely an optimization
over the Category 4 algorithm; the results obtained either way will be
identical.

At least I think so. :-)

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




More information about the cxx-abi-dev mailing list