This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/3332] friend function declaration in a class in a namespace causes error
- From: "lerdsuwa at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 11 Nov 2004 12:37:24 -0000
- Subject: [Bug c++/3332] friend function declaration in a class in a namespace causes error
- References: <20010621084601.3332.aroach@stoic.electriceyeball.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From lerdsuwa at gcc dot gnu dot org 2004-11-11 12:37 -------
Taking this bug. The code
void N::func(void)
is rejected because the declaration
friend void func(void);
doesn't declare 'func' inside namespace 'N'.
A separate declaration is necessary before the
qualified ID form 'N::func' can be used. The
following code, compiles under como, confirmed
the above idea.
namespace N
{
class A;
}
class N::A
{
void x();
friend void func(void);
};
namespace N
{
void func(void); // declare func
}
void N::func(void) // after declaration
// can now defined using qualified name
{
N::A a;
a.x(); // access private function
}
int main()
{
return 0;
}
The bug will be fixed when problematic codes in libjava
(it assumes friends are in '::') are corrected.
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|nathan at gcc dot gnu dot |lerdsuwa at gcc dot gnu dot
|org |org
Status|SUSPENDED |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=3332