This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/16147] New: dynamic_cast fails to enforce accesssibility
- From: "gdr at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 Jun 2004 22:58:54 -0000
- Subject: [Bug c++/16147] New: dynamic_cast fails to enforce accesssibility
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Consider the following program
#include <assert.h>
struct A { virtual ~A() { } };
struct B : A { };
A* f() {
struct C : private B {
A* g() { return this; }
};
return (new C)->g();
}
int main()
{
assert(dynamic_cast<B*>(f()) == 0);
}
According to 5.2.7/8, I believe the assert should pass.
I'm seeing this behaviour on GCC-3.3.x and probably before that too.
--
Summary: dynamic_cast fails to enforce accesssibility
Product: gcc
Version: 3.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: gdr at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: plateform independent
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16147