This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/11952] REGRESSION: friend declaration handled as function call concerning access.


------- Additional Comments From victor dot judin at materna dot de  2004-08-27 11:13 -------
Subject: AW:  REGRESSION: friend declaration handled as fun
	ction call concerning access.

If will please take a look at the openstd page you mention you'll find the
folloowing( sorry for Rich-Text )
209. Must friend declaration names be accessible?
Section: 11.4  class.friend     Status: NAD     Submitter: Judy Ward
Date: 1 Mar 2000

11.4  class.friend, paragraph 7, says

    A name nominated by a friend declaration shall be accessible in the
scope of the class containing the friend declaration. 

Does that mean the following should be illegal?

    class A { void f(); };
    class B { friend void A::f(); }; // Error: A::f not accessible from B

I discussed this with Bjarne in email, and he thinks it was an editorial
error and this was not the committee's intention. The paragraph seems to
have been added in the pre-Kona (24 Sept 1996) mailing, and I could not find
anything in the previous meeting's (Stockholm) mailings which led me to
believe this was intentional. The only compiler vendor which I think
currently implements it is the latest release (2.43) of the EDG front end. 



-----Ursprüngliche Nachricht-----
Von: giovannibajo at libero dot it [mailto:gcc-bugzilla@gcc.gnu.org]
Gesendet: Freitag, 27. August 2004 13:01
An: victor.judin@materna.de
Betreff: [Bug c++/11952] REGRESSION: friend declaration handled as
function call concerning access.



------- Additional Comments From giovannibajo at libero dot it  2004-08-27
11:00 -------
> Sorry, that's totally idiotic.

Please, moderate your language.

> If I have 
> class A
> {
>  void f();
> public: 
>  A();
> ~A();
> };
> and 
> class B
> {
> //...
> friend class A();
> };
> the visibility of A::f() remains private.
>
I cannot comment on this because the testcase is invalid, you cannot 
write "friend class A()". I don't know what you meant.


The bug reported here is indeed invalid. The original testcase is the
following:

class A {
  void f();
};

struct B {
  friend void A::f();
};

the friend declaration means that A::f() is able to access B's private
members. 
But the declaration is invalid because A::f() is a private function, and
thus 
it is not accessible from B's scope. The standard says this very clearly:

"A name nominated by a friend declaration shall be accessible in the scope
of 
the class containing the friend declaration"

This is also mentioned in our webpage about recent changes to the compiler, 
http://gcc.gnu.org/gcc-3.4/changes.html.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |giovannibajo at libero dot
                   |                            |it


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11952

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11952


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]