The following code results in an error: namespace Foo { template <typename T> void foo();} struct Bar { friend void Foo::foo<int>(); }; The error is: /home/stefan/friend.cc:4: error: ‘void Foo::foo()’ should have been declared inside ‘Foo’ I've briefly attempted to debug this. Here are my findings: At some point set_decl_namespace() is called for the friend declaration, which itself then checks the function against existing declarations in an iteration over the overload set. In case of a non-templated function, decls_match() would return true, but for the above function template it doesn't match, and so we enter the 'complain' label. Sorry I wasn't able to decipher the actual tree comparisons. HTH...
This is a dup of bug 8355. *** This bug has been marked as a duplicate of 8355 ***