problem with friend and namespaces

Martin v. Loewis
Wed Jun 28 14:06:00 GMT 2000

> Is there a problem with friend declarations inside namespaces or with the
> support of the '::' operator ?

Thanks for your bug report. This is indeed a known bug in g++. Please
note that there is an inherent ambiguity in C++, also. If you have

  friend A::B::f();

is that

  friend A ::B::f(); //function f in namespace B returning A


  friend A::B ::f(); //global function f returning A::B

This is no problem in your example, but it should give you an idea
about the parsing problems that arise. I had a patch fixing your case
at one time, but it broke other (more important) cases. As a result,
you cannot have qualified names in a friend declaration in g++, sorry.
If somebody volunteers to rewrite the C++ parser, there'd be a chance
that this bug would get fixed as well.


More information about the Gcc-bugs mailing list