https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88744
Bug ID: 88744
Summary: class non-type template parameters doesn't work with
default template parameters
Product: gcc
Version: 9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: mpolacek at gcc dot gnu.org
Target Milestone: ---
This ought to work:
struct S {
int a;
int b;
};
template<S s = {1, 2}> struct X {};
X x; // ok, X<{1, 2}>
but we reject it with:
z.C:7:3: error: class template argument deduction failed:
7 | X x; // ok, X<{1, 2}>
| ^
z.C:7:3: error: no matching function for call to ‘X()’
z.C:6:31: note: candidate: ‘template<S s> X()-> X<s>’
6 | template<S s = {1, 2}> struct X {};
| ^
z.C:6:31: note: template argument deduction/substitution failed:
z.C:6:21: error: could not convert ‘{1, 2}’ from ‘<brace-enclosed initializer
list>’ to ‘S’
6 | template<S s = {1, 2}> struct X {};
| ^