public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: dbaron@fas.harvard.edu To: gcc-gnats@gcc.gnu.org Cc: scc@mozilla.org Subject: c++/3765: member using declaration can't change access from public Date: Sun, 22 Jul 2001 18:56:00 -0000 [thread overview] Message-ID: <20010723015551.16473.qmail@sourceware.cygnus.com> (raw) >Number: 3765 >Category: c++ >Synopsis: member using declaration can't change access from public >Confidential: no >Severity: serious >Priority: medium >Responsible: unassigned >State: open >Class: accepts-illegal >Submitter-Id: net >Arrival-Date: Sun Jul 22 18:56:00 PDT 2001 >Closed-Date: >Last-Modified: >Originator: David Baron >Release: gcc 3.0 >Organization: >Environment: Linux 2.2.14-5.0smp i686 (RedHat 6.2) >Description: A C++ using declaration cannot be used to change member access from public to private or from public to protected. (Other combinations seem to work correctly.) This is a regression that occurred between egcs 1.1.2 and gcc 2.95.2 and still exists in gcc 3.0. (The error message given on the occasions where the |using| declaration works correctly also doesn't make much sense, since it gives the access that was overridden by the |using| even though it correctly changes the access. But that's another bug.) This is useful for things such as ensuring that users do not attempt to manually refcount an COM smart pointer: http://lxr.mozilla.org/seamonkey/source/xpcom/base/nsCOMPtr.h#159 >How-To-Repeat: Try to compile test case #1 or #4. Compilation succeds even though it should not. Test case #1: =========== /* vim:cindent:ai:sw=2:et:ts=8:tw=72: * * Demonstration of bug in gcc 3.0 where |using| does not change access * from public to private. * * ILLEGAL EXAMPLE * Test of changing access from public to private. * * See C++ standard, section 11.3 and 7.3.3. */ class A { public: int foo() { return 1; } }; class B : public A { private: using A::foo; }; int main() { B b; return b.foo(); // Should not compile. } =========== Test case #2: =========== /* vim:cindent:ai:sw=2:et:ts=8:tw=72: * * Demonstration of bug in gcc 3.0 where |using| does not change access * from public to private. * * LEGAL EXAMPLE * Test of changing access from protected to public. * * See C++ standard, section 11.3 and 7.3.3. */ class A { protected: int foo() { return 0; } }; class B : public A { public: using A::foo; }; int main() { B b; return b.foo(); } =========== Test case #3: =========== /* vim:cindent:ai:sw=2:et:ts=8:tw=72: * * Demonstration of bug in gcc 3.0 where |using| does not change access * from public to private. * * ILLEGAL EXAMPLE * Test of changing access from protected to private. * * See C++ standard, section 11.3 and 7.3.3. */ class A { protected: int foo() { return 1; } }; class B : public A { private: //protected: using A::foo; }; class C : public B { public: C() { B::foo(); } }; int main() { C c; return 1; } =========== Test case #4: =========== /* vim:cindent:ai:sw=2:et:ts=8:tw=72: * * Demonstration of bug in gcc 3.0 where |using| does not change access * from public to private. * * ILLEGAL EXAMPLE * Test of changing access from public to private. * * See C++ standard, section 11.3 and 7.3.3. */ class A { public: int foo() { return 1; } }; class B : public A { private: using A::foo; }; class C : public B { public: C() { foo(); } }; int main() { C c; return 1; } =========== Test case #5: =========== /* vim:cindent:ai:sw=2:et:ts=8:tw=72: * * Demonstration of bug in gcc 3.0 where |using| does not change access * from public to private. * * LEGAL EXAMPLE * Test of changing access from protected to public. * * See C++ standard, section 11.3 and 7.3.3. */ class A { protected: int foo() { return 0; } }; class B : public A { public: using A::foo; }; int main() { B b; return b.foo(); } =========== >Fix: >Release-Note: >Audit-Trail: >Unformatted:
next reply other threads:[~2001-07-22 18:56 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-07-22 18:56 dbaron [this message] 2002-07-23 7:49 lerdsuwa
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=20010723015551.16473.qmail@sourceware.cygnus.com \ --to=dbaron@fas.harvard.edu \ --cc=gcc-gnats@gcc.gnu.org \ --cc=scc@mozilla.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).