From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20594 invoked by alias); 31 Oct 2005 10:29:05 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 20578 invoked by uid 48); 31 Oct 2005 10:29:01 -0000 Date: Mon, 31 Oct 2005 10:29:00 -0000 Subject: [Bug c++/24592] New: Static_cast loses access to protected X-Bugzilla-Reason: CC Message-ID: Reply-To: gcc-bugzilla@gcc.gnu.org To: gcc-bugs@gcc.gnu.org From: "igodard at pacbell dot net" X-SW-Source: 2005-10/txt/msg04117.txt.bz2 List-Id: The code: template struct b1 { protected: void inc() {} T* dummy; }; templateclass F> struct b2 { void f() { F* s = static_cast*>(this); s->inc(); } }; template struct G : public b1, public b2 { }; int main() { G g; g.f(); } gets you: ~/ootbc/members/src$ g++ foo.cc foo.cc: In member function `void b2::f() [with T = int, F = G]': foo.cc:22: instantiated from here foo.cc:4: error: `void b1::inc() [with T = int]' is protected foo.cc:11: error: within this context The access to "inc" is "s->inc()". "s" is a "F", which after parameter substitution is a "G". "b2" is a public base of G, which after substitution means that "b2" is a public base of "G" and so is also a public base of "s". Hence the protected member "b2::inc" should be visible via "s", but is not. Ivan -- Summary: Static_cast loses access to protected Product: gcc Version: 3.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: igodard at pacbell dot net http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24592