In the program as follows, static function A::f has an automatically deduced return type. Despite it is defined in the code before its usage in default template parameter class T = decltype(A::f()):
struct A{
static auto f() {}
template<class T = decltype(A::f())>
friend void g(A) {}
};
int main(){
g(A{});
}
Clang refuses the program with the error:
function 'f' with deduced return type cannot be used before it is defined
while GCC is fine with the code, demo: https://gcc.godbolt.org/z/5Tc879od8
Which compiler is right here?