The following code should NOT compile; yet gcc accepts it. template <typename T> class Base { public: typedef int Foo; void MethodInBase(Foo x) {} };
template <typename T> class Derived : public Base<T> { public: typedef typename Base<T>::Foo Foo; Derived() { // According to C++ standard [14.6.4], the following line SHOULD // NOT COMPILE. Yet gcc and MSVC accept it. clang and comeau // reject it correctly. MethodInBase(Foo()); // This is the right way to write it: this->MethodInBase(Foo()); } }; int main() { Derived<void> foo; } -- Summary: gcc should reject code violating the C++ two-phase look- up rules. Product: gcc Version: 4.2.4 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: wan at google dot com http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42291