https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101811
Bug ID: 101811
Summary: Error not helpful for misplaced 'template'
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: tobi at gcc dot gnu.org
Target Milestone: ---
This is a bad error message that caught my eye while refactoring some code
(https://godbolt.org/z/558vM4Wb3):
struct X {
void f();
};
template<int i> // this line should not be here
void X::f()
{}
gives:
<source>:6:6: error: no declaration matches 'void X::f()'
6 | void X::f()
| ^
<source>:2:10: note: candidate is: 'void X::f()'
2 | void f();
| ^
<source>:1:8: note: 'struct X' defined here
1 | struct X {
| ^
Note that the error message doesn't actually include what's wrong and so it is
fairly confusing until you actually look at the code.