From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28211 invoked by alias); 10 Mar 2003 14:26:01 -0000 Mailing-List: contact gcc-prs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-prs-owner@gcc.gnu.org Received: (qmail 28193 invoked by uid 71); 10 Mar 2003 14:26:01 -0000 Resent-Date: 10 Mar 2003 14:26:01 -0000 Resent-Message-ID: <20030310142601.28191.qmail@sources.redhat.com> Resent-From: gcc-gnats@gcc.gnu.org (GNATS Filer) Resent-Cc: gcc-prs@gcc.gnu.org, gcc-bugs@gcc.gnu.org Resent-Reply-To: gcc-gnats@gcc.gnu.org, thor@math.tu-berlin.de Received: (qmail 27157 invoked by uid 48); 10 Mar 2003 14:21:17 -0000 Message-Id: <20030310142117.27156.qmail@sources.redhat.com> Date: Mon, 10 Mar 2003 14:26:00 -0000 From: thor@math.tu-berlin.de Reply-To: thor@math.tu-berlin.de To: gcc-gnats@gcc.gnu.org X-Send-Pr-Version: gnatsweb-2.9.3 (1.1.1.1.2.31) Subject: c++/10016: g++ allows access to static private class members if initialized X-SW-Source: 2003-03/txt/msg00475.txt.bz2 List-Id: >Number: 10016 >Category: c++ >Synopsis: g++ allows access to static private class members if initialized >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: accepts-illegal >Submitter-Id: net >Arrival-Date: Mon Mar 10 14:26:01 UTC 2003 >Closed-Date: >Last-Modified: >Originator: Thomas Richter >Release: g++ (GCC) 3.2 >Organization: >Environment: Linux i386 >Description: g++ accepts the following code without generating a warning or an error, though it should warn about trying to access the private member "foo" of class A: /* snip */ class A { static int foo; }; int A::foo = 42; class B : public A { public: int MyFoo(void) { return foo; } }; int main(int argc,char **argv) { class B b; return b.MyFoo(); } >How-To-Repeat: Save the above program as "foo.cpp", then compile as follows: $ g++ -Wall foo.cpp g++ will compile the program without generating an error or a warning, even though A::foo is private within B::MyFoo. g++ will warn if the initializer for A::foo is moved out of sight. >Fix: >Release-Note: >Audit-Trail: >Unformatted: