https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96321
Bug ID: 96321 Summary: GCC accepts conversion-function-id after the keyword template Product: gcc Version: 11.0 Status: UNCONFIRMED Keywords: accepts-invalid Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: language.lawyer at gmail dot com Target Milestone: --- struct S { template<typename T> operator T() { return T(); } }; int i = S().template operator int(); The code is accepted by GCC, when it shouldn't be. C++11 [temp.names]/5: A name prefixed by the keyword `template` shall be a template-id or the name shall refer to a class template. template-id: simple-template-id operator-function-id < template-argument-list[opt] > literal-operator-id < template-argument-list[opt] > So, conversion-function-id is not a template-id. Code is also probably invalid in C++98/03. C++03 [temp.names]/5 says: If a name prefixed by the keyword `template` is not the name of a member template, the program is ill-formed.