This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: dynamic cast bug.
- To: kenelson at ece dot ucdavis dot edu
- Subject: Re: dynamic cast bug.
- From: "Martin v. Loewis" <martin at loewis dot home dot cs dot tu-berlin dot de>
- Date: Mon, 26 Jun 2000 09:47:13 +0200
- CC: kenelson at ece dot ucdavis dot edu, gcc-bugs at gcc dot gnu dot org, kenelson at elm dot ece dot ucdavis dot edu
- References: <200006260117.SAA03633@elm.ece.ucdavis.edu>
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