This code has erroneously been accepted since at least gcc 2.95: -------------------------- namespace NS { template <int A, int B> class X {}; } class Y { template <int> friend class NS::X; }; -------------------------- Note the wrong number of template arguments in the friend declaration. The code is correctly rejected if X is not in a namespace. W.
Confirmed.
*** Bug 43960 has been marked as a duplicate of this bug. ***
Dup. *** This bug has been marked as a duplicate of bug 43694 ***