public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: thor@math.tu-berlin.de To: gcc-gnats@gcc.gnu.org Subject: c++/10016: g++ allows access to static private class members if initialized Date: Mon, 10 Mar 2003 14:26:00 -0000 [thread overview] Message-ID: <20030310142117.27156.qmail@sources.redhat.com> (raw) >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:
next reply other threads:[~2003-03-10 14:26 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2003-03-10 14:26 thor [this message] 2003-03-10 15:49 bangerth
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20030310142117.27156.qmail@sources.redhat.com \ --to=thor@math.tu-berlin.de \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).