The following example compiles cleanly with g++, while I think the "friend" declaration should be rejected, as the templated private class "A::Inner" should not be visible except from within A.
#include <iostream> class A { public: static int h(); private: template<typename T> struct Inner { static int f(); }; }; class B { friend class A::Inner<int>; // Should not be visible static int g() { return 42; } }; template<> int A::Inner<int>::f() { return B::g(); } int A::h() { return Inner<int>::f(); } int main() { std::cout << A::h() << std::endl; } -- Summary: Templated private class visible through friend declaration Product: gcc Version: 4.4.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sam at gcc dot gnu dot org GCC host triplet: x86_64-unknown-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37775