http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56820
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |accepts-invalid Status|UNCONFIRMED |NEW Last reconfirmed| |2013-11-16 Ever confirmed|0 |1 --- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> --- Confirmed. namespace outer { template<class T> struct B; namespace inner { template<class U> class A { template<class T> friend struct B; A() {} }; } template<class T> struct B { B() { inner::A<int> a; } }; } outer::B<int> b; The friend declaration only matches outer::B when both A and B are class templates. If either is a non-template then the friend declaration correctly declares outer::inner::B.