http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55436
Bug #: 55436 Summary: g++ compiles invalid code with child class of nested class in template class Classification: Unclassified Product: gcc Version: 4.7.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: conradsand.a...@gmail.com Created attachment 28760 --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28760 test.cpp: source for invalid code that compiles under g++ The code below compiles under g++ 4.7.2 and 4.4.6, but is apparently invalid, ie. it is not rejected by g++. We initially thought this was a bug in the clang compiler, but the clang folks are saying that this is a bug in g++ (ie. gcc shouldn't be accepting this code). Related clang bugzilla bug entry: http://llvm.org/bugs/show_bug.cgi?id=14402 The clang folks are quoting this part of the standard: See [temp.dep]p3: "In the definition of a class or class template, if a base class depends on a template-parameter, the base class scope is not examined during unqualified name lookup either at the point of definition of the class template or member or during an instantiation of the class template or member." #include <iostream> template<typename T> class A { public: void m() { std::cout << "A::m()" << std::endl; } void z() { m(); } class B { public: void m() { std::cout << "B::m()" << std::endl; } void y() { m(); } }; class C : public B { public: void x() { m(); } }; }; int main() { A<double> a; a.z(); A<double>::B b; b.y(); A<double>::C c; c.x(); } Clang 3.1 reports the following error: test.cpp:20:16: error: call to non-static member function 'm' of 'A' from nested type 'C' void x() { m(); } Shouldn't g++ also report a similar error?