https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117422
--- Comment #7 from Jesse Williamson <nerd.cpp at gmail dot com> --- Revisiting this, I don't think it's a bug-- but perhaps a more specific error message could have saved some confusion. See update: https://godbolt.org/z/sePdf4bvv ...adding scope resolution to the friend declaration in the class appears to produce the correct match, so I'm thinking that the unqualified version was causing the compiler to treat it as a forward declaration of a class member rather than a free function: template <typename T> void f(T x) {} /* Note: same error with: void f(auto x) {} */ struct { void f(int); friend void ::f<>(int); // <--- remove :: to see non-bug } foo;