dynamic cast bug.

Martin v. Loewis martin@loewis.home.cs.tu-berlin.de
Mon Jun 26 00:49:00 GMT 2000


Thanks again for your bug report. I've put it into GNATS.

The bug is that the typeinfo objects are incorrect for objects under
construction, if virtual bases are used (in particular, the offsets to
subobjects are incorrect; they apply to a full B0 object, not to a
B0-in-B1 object). The compiler would need to emit a different set of
type info objects, but doesn't (except for the new ABI, and for the
vtable-thunks>1 ABI of 2.95.3, there would be no way to pass those
typeinfo objects, either). This will likely be fixed with the new ABI
in gcc 3.

As a result, you cannot dynamic_cast in a constructor if the only
virtual function originates from a virtual base. As a work-around, you
can add an arbitrary virtual function to O2. That still wouldn't allow
dynamic_casting from O1 to O4 in the constructor.

Regards,
Martin


More information about the Gcc-bugs mailing list