diff options
author | Patrick Palka <ppalka@redhat.com> | 2020-07-29 22:06:41 -0400 |
---|---|---|
committer | Patrick Palka <ppalka@redhat.com> | 2020-07-29 22:06:41 -0400 |
commit | 71141b1bd537cc516e485c834c2d36abba3f4544 (patch) | |
tree | 3a2a2dc206c084c9574823d7fa1bcf9115b95129 | |
parent | f31dd9beb95f4beda1d2bd5c0526c42d0ce455c4 (diff) | |
download | gcc-71141b1bd537cc516e485c834c2d36abba3f4544.zip gcc-71141b1bd537cc516e485c834c2d36abba3f4544.tar.gz gcc-71141b1bd537cc516e485c834c2d36abba3f4544.tar.bz2 |
c++: alias_ctad_tweaks and constrained dguide [PR95486]
In the below testcase, we're ICEing from alias_ctad_tweaks ultimately
because the implied deduction guide for X's user-defined constructor
already has constraints associated with it. We then carry over these
constraints to 'fprime', the overlying deduction guide for the alias
template Y, via tsubst_decl from alias_ctad_tweaks. Later in
alias_ctad_tweaks we call get_constraints followed by set_constraints
without doing remove_constraints in between, which triggers the !found
assert in set_constraints.
This patch fixes this issue by adding an intervening call to
remove_constraints.
gcc/cp/ChangeLog:
PR c++/95486
* pt.c (alias_ctad_tweaks): Call remove_constraints before
calling set_constraints.
gcc/testsuite/ChangeLog:
PR c++/95486
* g++.dg/cpp2a/class-deduction-alias3.C: New test.
-rw-r--r-- | gcc/cp/pt.c | 5 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp2a/class-deduction-alias3.C | 11 |
2 files changed, 15 insertions, 1 deletions
diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 15be7b6..a7ab2bd 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -28620,7 +28620,10 @@ alias_ctad_tweaks (tree tmpl, tree uguides) } if (ci) - set_constraints (fprime, ci); + { + remove_constraints (fprime); + set_constraints (fprime, ci); + } } else { diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias3.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias3.C new file mode 100644 index 0000000..318d4c9 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias3.C @@ -0,0 +1,11 @@ +// PR c++/95486 +// { dg-do compile { target c++20 } } + +template<class T, class U> +struct X { X(U) requires __is_same(U, int) {} }; + +template<class U> +using Y = X<void, U>; + +Y y{1}; +Y z{'a'}; // { dg-error "failed|no match" } |