https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117390
Bug ID: 117390
Summary: Error message for trying to call an constructor with
template arguments should be improved
Product: gcc
Version: 15.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: enhancement
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: pinskia at gcc dot gnu.org
Target Milestone: ---
Take:
```
struct foo {
template<typename T>
foo(T i) {}
};
struct foo1 : foo {
foo1 () : foo<int>(1) {}
};
```
Currently the error message we get is:
```
<source>: In constructor 'foo1::foo1()':
<source>:7:15: error: 'struct foo foo::foo' is not a non-static data member of
'foo1'
7 | foo1 () : foo<int>(1) {}
| ^~~
<source>:7:18: error: expected '(' before '<' token
7 | foo1 () : foo<int>(1) {}
| ^
```
But it is not obvious why from the error message the code is invalid. Basically
you can't call a constructor with template arguments, only have them deduced.
Note clang is just produces a `error: expected '(' or '{'` and pointing to the
`<` so it is slightly worse.
EDG is only slightly better than both GCC and clang:
```
"<source>", line 7: error: foo is not a template
foo1 () : foo<int>(1) {}
^
```