Topic: vtbl" in C++
Author: hpa@transmeta.com (H. Peter Anvin)
Date: 1997/03/27 Raw View
Followup to: <333852D9.3AED@statestreet.com>
By author: nospam@svna0001.clipper.ssb.com
In newsgroup: comp.std.c++
>
> i seem to recollect from somewhere that the "common" implementation
> of virtual function pointers as a "vtbl" has never been mandated by
> the language.
>
> can someone back me or correct me and point me to the right place?
>
That is correct, and at least one other implementation (thunks) is
moderately common. Neither is the common implementation of type-safe
linkage by mangling names mandated. In either case, it is a compiler
implementation or an ABI issue, rather than a language issue. The
choice of vtbls versus thunks is likely to depend on the
characteristics of the target architecture.
-hpa
--
Always looking for a few good BOsFH. ** Linux - the OS of global cooperation
I am Bah=E1'=ED -- ask me about it or see http://www.bahai.org/
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Author: kv <wontgiveout@spammers.junk>
Date: 1997/03/25 Raw View
hi
i seem to recollect from somewhere that the "common" implementation
of virtual function pointers as a "vtbl" has never been mandated by
the language.
can someone back me or correct me and point me to the right place?
thanx
kv
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Author: Stephen.Clamage@eng.sun.com (Steve Clamage)
Date: 1997/03/26 Raw View
In article 3AED@statestreet.com, kv <wontgiveout@spammers.junk> writes:
>
>i seem to recollect from somewhere that the "common" implementation
>of virtual function pointers as a "vtbl" has never been mandated by
>the language.
>
>can someone back me or correct me and point me to the right place?
>thanx
>kv
There isn't any place. Vtables are simply not discussed at all in
the draft standard.
The draft just describes the behavior of virtual functions. As long
as the implementation gets the behavior right, it doesn't matter
how it gets that behavior.
The fundamentals of vtables as described in the ARM, which I would
characterize as
- the virtual functions in class each have an index number
- one table of virtual functions is shared among many objects
of a given type
- objects contain a pointer to the vtable for that type
- virtual function calls are implemented as indirection via the table
are common to probably all implementations. That is because it is
reasonably easy to implement and is probably at least as efficient
overall as any other method.
Even so, the major C++ compiler vendors use vtable implementations
that differ in detail, particularly when multiple inheritance is
considered. The ARM describes at least two vtable implementations,
but doesn't demand that any particular implementation be used.
---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ comp.std.c++ is moderated. To submit articles: try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]