[Bug c++/37701] New: dynamic_cast to void cv* wrongly allowed with -fno-rtti
algrant at acm dot org
gcc-bugzilla@gcc.gnu.org
Wed Oct 1 15:36:00 GMT 2008
Compiled -fno-rtti, g2 and g3 are faulted but g1 is not. Code for g1
(on ARM target) shows use of RTTI which we have asserted is absent.
struct B1 { virtual int f(); };
struct B2 { virtual int g(); };
struct D: B1, B2 { };
/* These should be allowed even with -fno-rtti */
B1 *f2(B1 *p) { return dynamic_cast<B1 *>(p); }
B1 *f3(D *p) { return dynamic_cast<B1 *>(p); }
/* These should not be allowed with -fno-rtti */
/* gABI 2.9.4 case #1: dynamic cast<void cv*>, which returns a pointer to the
complete lvalue */
void *g1(B1 *p) { return dynamic_cast<void *>(p); }
/* gABI 2.9.4 case #2: dynamic cast operation from a proper base class to a
derived clasB1 */
D *g2(B1 *p) { return dynamic_cast<D *>(p); }
/* gABI 2.9.4 case #3: dynamic_cast across the hierarchy which can be seen as a
cast to the complete lvalue and back to a sibling base */
B1 *g3(B2 *p) { return dynamic_cast<B1 *>(p); }
--
Summary: dynamic_cast to void cv* wrongly allowed with -fno-rtti
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: algrant at acm dot org
GCC target triplet: ARM
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37701
More information about the Gcc-bugs
mailing list