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); }
*** Bug 37701 has been marked as a duplicate of this bug. ***
Bug report in error.