The following is adapted from the example from the C++ standard, clause 14.6/4 (actually it's the updated version from DR345):
1 struct A { 2 struct X { }; 3 static int X; 4 } ; 5 template<class T> void f(T t) { 6 typename T::X x; // invalid 7 T::X y; // invalid 8 int z = T::X; // OK 9 } 10 void foo() { 11 A a; 12 f(a); // error: T::X refers to the data member A::X not 13 // the struct A::X. 14 } I've removed the `B' class from the example, made A::X static (so that T::X may be used to reference it), and added lines 7 and 8. According to the standard, clause 14.6/4, all the `T::X' should find the data member X, *not* the type member X, regardless of the `typename' keyword. In this case, however, GCC 4.1.1 has not done this, and gives the following diagnostics: t.cxx: In function void f(T): t.cxx:7: error: expected `;' before y Line 6 has been compiled OK; `T::X' has found the type. Line 7 has been rejected correctly; `T::X' has not found a type, which means the `typename' keyword in line 6 was significant. Line 8 has been compiled correctly; `T::X' has found the data member. -- Summary: member/type lookup doesn't work properly with templates Product: gcc Version: 4.1.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: andrew dot stubbs at st dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32066