http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55668
Bug #: 55668 Summary: Incorrect lookup for template member of dependent template Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: tud...@fb.com The following correct program gives an error; it appears that "a.template foo<0>" looks up foo in global scope and fails because it believes that foo takes a class first template argument instead of an int. // The bug is not triggered if the template below is missing, // or if it is a class or function or global variable instead of // a template. template <class T> class foo; template <int N> struct A { template <int K> void foo(int val) { } }; template <int N> struct B { // The bug is not triggered if "bar" is named "foo" void bar() { a.template foo<0>(42); } // This has to depend on N; A<0> doesn't trigger the bug A<N> a; }; The error I get: d.cpp: In member function `void B<N>::bar()`: d.cpp:13:21: error: type/value mismatch at argument 1 in template parameter list for `template<class T> class foo` d.cpp:13:21: error: expected a type, got `0` Broken in 4.1.2, 4.6.2, 4.7.1 (the three versions I have access to). (The bug was minimized from actual code, in which the method in question was named "set" and collided with std::set, as we had "using std::set")