Re: use of vtbl

"Bill Gibbons" <bill@gibbons.org>
10 Aug 2002 02:34:37 -0400

          From comp.compilers

Related articles
use of vtbl Michael.Bantle@t-systems.de (Michael BANTLE) (2001-08-06)
Re: use of vtbl fjh@cs.mu.OZ.AU (2001-08-08)
Re: use of vtbl zoicasc@hotmail.com (Cristian Zoicas) (2002-08-04)
Re: use of vtbl gdr@soliton.integrable-solutions.net (Gabriel Dos Reis) (2002-08-10)
Re: use of vtbl mal@wyrd.be (Lieven Marchand) (2002-08-10)
Re: use of vtbl bill@gibbons.org (Bill Gibbons) (2002-08-10)
Re: use of vtbl haberg@matematik.su.se (Hans Aberg) (2002-08-14)
Re: use of vtbl loewis@informatik.hu-berlin.de (Martin v. =?iso-8859-1?q?L=F6wis?=) (2002-08-14)
| List of all articles for this month |

From: "Bill Gibbons" <bill@gibbons.org>
Newsgroups: comp.compilers
Date: 10 Aug 2002 02:34:37 -0400
Organization: -none-
References: 01-08-021 02-08-018
Keywords: C++
Posted-Date: 10 Aug 2002 02:34:37 EDT

The moderator wrote:


> [I gather that the C++ standards committee came very close to defining
> the structure of a vtbl, so portable code could mess with them. I
> suspect you'll find that no matter which compiler you use, the vtbls are
> all about the same. -John]


No, the C++ standards committee deliberately avoided defining the
structure of a vtbl. For example, failure to define a virtual
function that cannot ever be called is an error but no diagnostic is
required because there are ways to implement virtual functions without
using vtables.


There is more than one existing implementation of:


    * the location of a vtable pointer in an object


    * handling non-zero base class subobject offsets (multiple inheritance)


    * handling virtual functions in virtual base classes


    * handling construction-time offsets of virual base classes


    * ordering multiple base classes


    * sharing base class vtables


    * the relationship of pointers to member functions and vtable entries


Code that messes with vtables is only portable within the object model,
i.e. between two compilers that can generate object code that can be linked
together. Assuming, of course, that vtables exist at all in that
implementation.


It is about as portable as code that takes the address of a stack-based
variable and tries to manipulate the stack frame.


-- Bill Gibbons
[Yes, I said they didn't define the vtbl. Evidently whoever told me
they considered doing so lied to me. -John]



Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.