Bug 37697 - dynamic_cast to void cv* wrongly allowed with -fno-rtti
Summary: dynamic_cast to void cv* wrongly allowed with -fno-rtti
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
: 37701 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-10-01 14:21 UTC by algrant
Modified: 2008-10-01 16:40 UTC (History)
1 user (show)

See Also:
Host:
Target: ARM
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description algrant 2008-10-01 14:21:35 UTC
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); }
Comment 1 algrant 2008-10-01 15:35:54 UTC
*** Bug 37701 has been marked as a duplicate of this bug. ***
Comment 2 algrant 2008-10-01 16:40:44 UTC
Bug report in error.