Bug 7809 - befriending inaccessible names
Summary: befriending inaccessible names
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 3.2
: P3 normal
Target Milestone: 3.4.0
Assignee: Kriang Lerdsuwanakij
URL:
Keywords: accepts-invalid
: 19868 22009 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-09-02 06:46 UTC by bagnara
Modified: 2005-06-10 19:24 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-07-05 23:24:15


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description bagnara 2002-09-02 06:46:02 UTC
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
$
Comment 1 Wolfgang Bangerth 2002-10-28 14:55:07 UTC
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.
Comment 2 Kriang Lerdsuwanakij 2003-05-18 10:05:16 UTC
Responsible-Changed-From-To: unassigned->lerdsuwa
Responsible-Changed-Why: Will investigate.
Comment 3 Kriang Lerdsuwanakij 2003-06-16 13:48:33 UTC
Patch available:

  http://gcc.gnu.org/ml/gcc-patches/2003-06/msg01739.html
Comment 4 GCC Commits 2003-07-17 15:47:52 UTC
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

Comment 5 Andrew Pinski 2003-07-17 18:05:59 UTC
Kriang are you going to ask for inclusion for 3.3.2, or should this be closed?
Comment 6 Kriang Lerdsuwanakij 2003-07-18 14:04:48 UTC
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





Comment 7 Andrew Pinski 2003-07-18 14:10:43 UTC
Fixed in the mainline (which will become 3.4) by the patch above.
Comment 8 Andrew Pinski 2005-02-09 20:13:43 UTC
*** Bug 19868 has been marked as a duplicate of this bug. ***
Comment 9 Andrew Pinski 2005-06-10 19:24:57 UTC
*** Bug 22009 has been marked as a duplicate of this bug. ***