This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11952] REGRESSION: friend declaration handled as function call concerning access.
- From: "giovannibajo at libero dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Aug 2004 11:00:31 -0000
- Subject: [Bug c++/11952] REGRESSION: friend declaration handled as function call concerning access.
- References: <20030816225616.11952.carlo@alinoe.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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