Virtual function calls

Mark Mitchell mark at codesourcery.com
Sun Jan 30 01:36:36 UTC 2000


This is a nit.

I don't think:

  The caller adjusts the 'this' argument to point to the class which
  last overrode the function being called. The result provides both the
  'this' argument and the vtable pointer for finding the function we
  want.

is very clear.  For example, consider:

  struct S1 { virtual void f(); };
  struct S2 : virtual public S1 { virtual void f(); };
  struct T : virtual public S1, virtual public S2 {};

This is legal C++, but is `S2' or `S1' the base which last overrode
`f'?  The answer is `S2', but we need to find a better way of
expressing this.

I think its easiest to use terms straight out of the standard:

  The caller adjusts the `this' argument to point to the class
  that contains the unique final overrider (as defined in
  [class.virtual]) for the function being called.  The result provides
  both the 'this' argument and the vtable pointer for finding the
  function we want.

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




More information about the cxx-abi-dev mailing list