The following snippet (call it bug.cc) compiles whereas, according to the standard (11p3 and 11.4p7), it should not: class A { private: void f(); public: A(); }; class B { friend void A::f(); }; Release: unknown Environment: $ uname -a Linux zoltan.unisuv.it 2.4.19 #23 Sun Aug 4 18:03:23 CEST 2002 i686 unknown $ gcc -v Reading specs from /usr/local/lib/gcc-lib/i686-pc-linux-gnu/3.2/specs Configured with: ../gcc-3.2/configure --prefix=/usr/local Thread model: posix gcc version 3.2 How-To-Repeat: $ g++ -c -W -Wall bug.cc $
State-Changed-From-To: open->analyzed State-Changed-Why: As annoying as it seems, this is what the standard indeed says. There is a defect report (http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/cwg_closed.html#209) on the matter, which was put into "Not a defect" status, meaning gcc is indeed non-conforming. Confirmed with present CVS.
Responsible-Changed-From-To: unassigned->lerdsuwa Responsible-Changed-Why: Will investigate.
Patch available: http://gcc.gnu.org/ml/gcc-patches/2003-06/msg01739.html
Subject: Bug 7809 CVSROOT: /cvs/gcc Module name: gcc Changes by: lerdsuwa@gcc.gnu.org 2003-07-17 15:47:40 Modified files: gcc/cp : ChangeLog friend.c gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/parse: access3.C Log message: PR c++/7809 * friend.c (add_friend): Check access for member functions and templates. * g++.dg/parse/access3.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3532&r2=1.3533 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/friend.c.diff?cvsroot=gcc&r1=1.87&r2=1.88 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2889&r2=1.2890 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/parse/access3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
Kriang are you going to ask for inclusion for 3.3.2, or should this be closed?
Subject: Re: befriending inaccessible names pinskia at physics dot uc dot edu wrote: >PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org. > >http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7809 > > > >------- Additional Comments From pinskia at physics dot uc dot edu 2003-07-17 18:05 ------- >Kriang are you going to ask for inclusion for 3.3.2, or should this be closed? > > No, the internal infrastructure in 3.4 differs a lot from 3.3. The handling of friend in 3.3 there isn't quite correct yet. I have already disable a piece of access checking code intentionally to get around that problem. --Kriang
Fixed in the mainline (which will become 3.4) by the patch above.
*** Bug 19868 has been marked as a duplicate of this bug. ***
*** Bug 22009 has been marked as a duplicate of this bug. ***