Clang accepts invalid program involving template keyword when used without a template arg list
The following invalid program(as per [temp.name#6]) compiles with gcc and clang. Demo
template<typename T>
struct C
{
template<typename U> void func(U)
{
}
};
int main()
{
C<int> c;
c.template func(5); //this is invalid as per current wording gcc and clang accepts but msvc correctly rejects
//c.template func<>(5); //valid as per current wording. All compilers accepts this
}
@llvm/issue-subscribers-clang-frontend
Author: Anoop Rana (ranaanoop)
template<typename T>
struct C
{
template<typename U> void func(U)
{
}
};
int main()
{
C<int> c;
c.template func(5); //this is invalid as per current wording gcc and clang accepts but msvc correctly rejects
//c.template func<>(5); //valid as per current wording. All compilers accepts this
}
Wording: https://eel.is/c++draft/temp.names#6
https://cplusplus.github.io/CWG/issues/96.html
There is existing practice, so we can't simply implement the diagnostic as an error, but doing it as a pedantic wording would be a good idea
https://github.com/search?type=code&auto_enroll=true&q=lang%3Acpp+%2F%5C.template+%5Ba-zA-Z_%5D%5C%28%2F&p=1
Should this issue be closed as completed by #78595?