/ There should be no difference where friend declaration is made // inside class. But in fact at least under GCC 4.1.1 there is.
template <typename T> class CTest; template <typename T> T foo(const CTest<T> &test) { return test.m_data; } template <typename T> class CTest{ public: // In this place we can declare friend function foo //friend T foo<>(const CTest &test); T foo() { return m_data;} // But in that place we can not declare friend function foo friend T foo<>(const CTest &test); private: T m_data; }; int main() { return 0; } -- Summary: failure to check for visible declaration of friend function to template class Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: tkapela at poczta dot fm GCC target triplet: Linux Mandriva 2007 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30431