GCC Bugzilla – Bug 2330
static_cast<>() to a private base is allowed
Last modified: 2003-08-06 17:36:26 UTC
static_cast<>() from a derived type to its private base is allowed, but shouldn't. dynamic_cast<>() is okay on its side. Release: 2.95.3 Environment: Debian Linux (Woody) on Intel How-To-Repeat: #include <iostream> struct A { void foo() { std::cout << __PRETTY_FUNCTION__ << std::endl; } }; struct B : private A { }; int main() { B b; static_cast<A &>(b).foo(); }
State-Changed-From-To: open->analyzed State-Changed-Why: confirmed as a bug
From: nathan@gcc.gnu.org To: gcc-gnats@gcc.gnu.org, nobody@gcc.gnu.org, philippeb@corel.com Cc: Subject: Re: c++/2330 Date: 25 Apr 2001 15:26:16 -0000 Synopsis: static_cast<>() to a private base is allowed State-Changed-From-To: open->analyzed State-Changed-By: nathan State-Changed-When: Wed Apr 25 08:26:16 2001 State-Changed-Why: confirmed as a bug http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=2330&database=gcc
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu> To: gcc-gnats@gcc.gnu.org Cc: Subject: Re: c++/2330: static_cast<>() to a private base is allowed Date: Fri, 8 Nov 2002 09:07:23 -0600 (CST) This problem persists. It also appears with a C-style cast like (Base*)derived_object, see PR 8500. W. ------------------------------------------------------------------------- Wolfgang Bangerth email: bangerth@ticam.utexas.edu www: http://www.ticam.utexas.edu/~bangerth
From: "Giovanni Bajo" <giovannibajo@libero.it> To: <gcc-gnats@gcc.gnu.org>, <gcc-bugs@gcc.gnu.org>, <nobody@gcc.gnu.org>, <philippeb@corel.com>, <gcc-prs@gcc.gnu.org> Cc: "Wolfgang Bangerth" <bangerth@ices.utexas.edu> Subject: Re: c++/2330: [2003-01-01] static_cast<>() to a private base is allowed Date: Mon, 14 Apr 2003 05:48:00 +0200 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&p r=2330 Reconfirmed 2.95 -> 3.4 20030413 (bump date please) Giovanni Bajo
still happens on the mainline (20030615).
Fixed on the 3.3 branch and mainline. Probably by Mark's patch: http://gcc.gnu.org/ml/gcc-patches/2003-06/msg02907.html