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 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


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