This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: dynamic cast bug.


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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]