[Bug c++/99644] New: Add fix-it hint for
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Mar 18 13:14:34 GMT 2021
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=99644
Bug ID: 99644
Summary: Add fix-it hint for
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: redi at gcc dot gnu.org
Target Milestone: ---
Given:
template<typename T> struct S { };
template<typename T> requires (sizeof(T) == 1) struct S { };
This fails to compile with -std=gnu++20 as expected:
con.C:2:55: error: redeclaration 'template<class T> struct S' with different
constraints
2 | template<typename T> requires (sizeof(T) == 1) struct S { };
| ^
con.C:1:29: note: original declaration appeared here
1 | template<typename T> struct S { };
| ^
The user probably meant to declare the constrained template as a partial
specialization, not a redeclaration of the primary template (I do this all the
time). So a fix-it hint suggesting to add a template argument list would be
helpful:
note: did you mean to declare a partial specialization?
2 | template<typename T> requires (sizeof(T) == 1) struct S { };
| ^
| <T>
This could be suggested whenever a redeclaration of a template has exactly the
same template-parameter-list as the original declaration but different
constraints. The fix-it hint should suggest adding a template argument list
containing each of the template parameters.
More information about the Gcc-bugs
mailing list