[lug] g++ question: dynamic casts?

Tkil tkil at scrye.com
Wed Jan 30 21:57:31 MST 2002

for what it's worth, dynamic casts have more to do with vtables, not
with name mangling.  you might get into the latter when you start
mucking about with true RTTI (e.g. #include <typeinfo> or whatever it

  (ok, that's a bit of a fib: the most obvious implementation of
  dynamic_cast uses the vtable only to store a pointer to a RTTI
  structure of some type, then goes up a chain of RTTI structures
  until it finds one that's a match for the requested cast-to type, or
  until it ends the chain.  either way, it's very sensitive to the
  layout of the RTTI information, not the name mangling as such.  the
  latter should just give you link errors, really.)

having said that, there were ABI differences amongst 2.95, 2.96, and
3.0.  those should settle down in 3.0, but you're much better off
doing all your C++ compiles with the same major/minor compiler (e.g.,
2.95.2 and 2.95.3 probably mix well, but neither will be reliable with
2.96 nor 3.0)

one of the big advances of 3.0 is, in fact, the hope for a stable ABI
so that you *will* be able to mix different compiler versions in the
3.x series, at least.


ABI == "application binary interface", for what it's worth.  in the
case of c++, that typically includes exception handling, vtable
layout, RTTI, handling of virtual base classes and other multiple-
inheritance monsters, the aforementioned name mangling, and a few
other things.  Tom Romey will hopefully correct any errors in this
posting.  :)

More information about the LUG mailing list