http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58538
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- Possibly related is that G++ treats X as the class template here, not the injected class name, on contrast to other compilers: template< template< typename > class T > class factory { }; template< typename T > class X { friend class factory< X >; // *** }; int main() { }