The following program compiles with using clang HEAD 10.0.0
#include <iostream>
template <class T>
void f( const T & );
class A
{
public:
A( int x = 0 ) : x( x ) {}
friend void ::f( const A & );
private:
int x;
};
template <class T>
void f( const T &t )
{
std::cout << "t.x = " << t.x << '\n';
}
int main()
{
A a( 10 );
f( a );
}
The program output is
t.x = 10
But when the gcc HEAD 10.0.0 20190
compiler is used then it outputs the error
prog.cc:11:32: error: 'void f(const A&)' should have been declared inside '::'
11 | friend void ::f( const A & );
| ^
Is it a bug of the compiler or am I doing something wrong?