| Issue |
53095
|
| Summary |
`.template` not followed by template arguments is incorrectly accepted
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
HolyBlackCat
|
Consider this example:
```cpp
#include <iostream>
struct A
{
void foo() {std::cout << "1\n";}
template <typename T = int>
void foo() {std::cout << "2\n";}
};
int main()
{
A x;
x.template foo();
}
```
Clang prints `2`. But the code shouldn't be accepted at all, since [`[temp.names]/5`](https://timsong-cpp.github.io/cppwp/n3337/temp.names#5) says that the name after `.template`/`->template` must be a *template-id*, aka must have explicitly specified template arguments. [Here's a stackoverflow thread](https://stackoverflow.com/q/70635683/2752075).
**Note**: this doesn't apply to `foo::template MyClassTemplate`, which is legal, but seems to be made optional (and deprecated at the same time) in C++2b.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs