Summary: | derived class can access protected base class member function through pointer to member function | ||
---|---|---|---|
Product: | gcc | Reporter: | Mike Reed <mike.reed> |
Component: | c++ | Assignee: | Giovanni Bajo <giovannibajo> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | gcc-bugs, msebor, murrayc, pinskia, reichelt, richard.kreckel, smelkov |
Priority: | P2 | Keywords: | accepts-invalid, documentation, monitored |
Version: | 3.3 | ||
Target Milestone: | 3.4.0 | ||
Host: | Target: | ||
Build: | Known to work: | ||
Known to fail: | Last reconfirmed: | 2003-08-18 04:44:20 |
Description
Mike Reed
2003-06-12 12:59:56 UTC
Confirmed. Reduced snippet: --------------------------------- struct A { protected: int a; }; struct B : A { void foo() { (void)&A::a; } }; --------------------------------- This is accepted by any version of GCC but it is ill-formed (see the example in ยง11.5). Patch submitted: http://gcc.gnu.org/ml/gcc-patches/2003-08/msg00998.html Subject: Bug 11174 CVSROOT: /cvs/gcc Module name: gcc Changes by: lerdsuwa@gcc.gnu.org 2003-08-19 12:55:00 Modified files: gcc/cp : ChangeLog init.c gcc/testsuite : ChangeLog gcc/testsuite/g++.old-deja/g++.jason: access17.C Added files: gcc/testsuite/g++.dg/parse: access4.C access5.C Log message: PR c++/11174 * init.c (build_offset_ref): Perform access checking for pointer to member correctly. * g++.dg/parse/access4.C: New test. * g++.dg/parse/access5.C: Likewise. * g++.old-deja/g++.jason/access17.C: Adjust error message. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3608&r2=1.3609 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/init.c.diff?cvsroot=gcc&r1=1.339&r2=1.340 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2976&r2=1.2977 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/access4.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/access5.C.diff?cvsroot=gcc&r1=NONE&r2=1.1 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.old-deja/g++.jason/access17.C.diff?cvsroot=gcc&r1=1.5&r2=1.6 Fixed in the main trunk. *** Bug 12119 has been marked as a duplicate of this bug. *** *** Bug 14894 has been marked as a duplicate of this bug. *** *** Bug 15308 has been marked as a duplicate of this bug. *** *** Bug 15468 has been marked as a duplicate of this bug. *** Reopening for documentation. I'll take care of writing up changes.html/bugs.html for this. It affects more than pointer-to-members, and appears to be a FAQ. Closing this one as PR 14949 is the one for the documenation. |