https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85514
Bug ID: 85514 Summary: g++ accepts invalid template code Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: Martin_Brehm at gmx dot de Target Milestone: --- Please consider the following (presumably) invalid C++ code: template<class T, template<class> class U> class A { public: A(int i) { (void)i; } }; template<class T> class B : public A<T,B> { public: //B(int i) : A<T,::B>(i) { } // valid B(int i) : A<T,B>(i) { } // invalid }; int main() { B<double> b(23); return 0; } Clang++ and Visual Studio 2017 reject this code, but g++ (7.3 and older versions) accepts it. This probably also concerns the gcc 8 trunk, but I did not have the opportunity to check it yet. To my understanding, the code is incorrect because the injected class name "B" should refer to the specialized class, and not to the generic template. The (commented out) valid code line is accepted by all three compilers.