Open llvmbot opened 9 years ago
As I said at https://gcc.gnu.org/#66836
Well friend void f();
can't match Outer::f
because you can't declare a member function like that except in the class' own scope. What GCC and Clang do is what the standard intended to say but fails to say clearly, which is Core issue 138 https://wg21.link/cwg138
Extended Description
Consider the following code, courtesy of Belloc (http://stackoverflow.com/q/31348475/2069064):
According to [namespace.memdef]/3,
There's some confusion as to what "outside" means in this context, but regardless both GCC and Clang are inconsistent in their interpretation. Either it means exclusively the innermost enclosing namespace (in which case both
::f
and::C
should be friends) or it just means stop at the innermost enclosing namespace (in which case bothOuter::f
andOuter::C
should be friends). But in this case, both GCC and Clang friend::f
andOuter::C
, which is a bug in one direction or the other.