https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82204
Bug ID: 82204 Summary: G++ doesn't connect friend and extern declarations Product: gcc Version: 8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: jason at gcc dot gnu.org Target Milestone: --- This testcase fails to link because the compiler doesn't associate the local extern with the friend, so it doesn't know we need to instantiate the friend. template <class T> struct A { friend void f(A*) { }; }; template <class T> void g(T* p) { extern void f(T*); f(p); } int main() { A<int> a; g(&a); }