From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2122) id 2E9753858031; Thu, 9 Mar 2023 15:28:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E9753858031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1678375682; bh=dU820eKAZ8vA0j+C7COJBfz37za0wL+Ffe9Ja9MQu40=; h=From:To:Subject:Date:From; b=ffpVEsK9hzoOgjqEfIu+YzADDjGTYKXFLpfWyg8B74ZDPvP/mQWlqw9+fUjdAgelM k1/z9uJWcPjB6ht0W8Nn0vaFNJc9EgHltAWJvtAjeZu08tMlDnOVjjJBHgutQng83o QWvKAvsvqnZahdoPQlblxRPKGq1mJiZcoFYiwMjw= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Jason Merrill To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-6556] c++: CTAD for less-specialized alias template [PR102529] X-Act-Checkin: gcc X-Git-Author: Jason Merrill X-Git-Refname: refs/heads/trunk X-Git-Oldrev: 9e6170098d5e7756e85e880f8f4cb18e885a64fd X-Git-Newrev: afe1f0c251d0429069c2414d4f3f14042efc174f Message-Id: <20230309152802.2E9753858031@sourceware.org> Date: Thu, 9 Mar 2023 15:28:02 +0000 (GMT) List-Id: https://gcc.gnu.org/g:afe1f0c251d0429069c2414d4f3f14042efc174f commit r13-6556-gafe1f0c251d0429069c2414d4f3f14042efc174f Author: Jason Merrill Date: Thu Feb 9 12:58:35 2023 -0800 c++: CTAD for less-specialized alias template [PR102529] The standard was unclear what happens with the transformation of a deduction guide if the initial template argument deduction fails for a reason other than not deducing all the arguments; my implementation assumed that the right thing was to give up on the deduction guide. But in consideration of CWG2664 this week I realized that we get a better result by just continuing with an empty set of deductions, so the alias deduction guide is the same as the original deduction guide plus the deducible constraint. DR 2664 PR c++/102529 gcc/cp/ChangeLog: * pt.cc (alias_ctad_tweaks): Continue after deduction failure. gcc/testsuite/ChangeLog: * g++.dg/DRs/dr2664.C: New test. * g++.dg/cpp2a/class-deduction-alias15.C: New test. Diff: --- gcc/cp/pt.cc | 4 +++- gcc/testsuite/g++.dg/DRs/dr2664.C | 17 +++++++++++++++++ gcc/testsuite/g++.dg/cpp2a/class-deduction-alias15.C | 18 ++++++++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 8c73ea5b0fa..65341c40f97 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -30072,7 +30072,9 @@ alias_ctad_tweaks (tree tmpl, tree uguides) tree targs = make_tree_vec (len); int err = unify (ftparms, targs, ret, utype, UNIFY_ALLOW_NONE, false); if (err) - continue; + /* CWG2664: Discard any deductions, still build the guide. */ + for (unsigned i = 0; i < len; ++i) + TREE_VEC_ELT (targs, i) = NULL_TREE; /* The number of parms for f' is the number of parms for A plus non-deduced parms of f. */ diff --git a/gcc/testsuite/g++.dg/DRs/dr2664.C b/gcc/testsuite/g++.dg/DRs/dr2664.C new file mode 100644 index 00000000000..f6bf8e2ecef --- /dev/null +++ b/gcc/testsuite/g++.dg/DRs/dr2664.C @@ -0,0 +1,17 @@ +// CWG 2664 +// { dg-do compile { target c++20 } } + +template struct C { + C(...); +}; + +template C(T1) -> C; +template C(T1, T2) -> C; + +template using A = C; + +C c1{""}; +A a1{""}; + +C c2{"", 1}; +A a2{"", 1}; diff --git a/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias15.C b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias15.C new file mode 100644 index 00000000000..db615faf8e2 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/class-deduction-alias15.C @@ -0,0 +1,18 @@ +// PR c++/102529 +// { dg-do compile { target c++20 } } + +template +struct C { + template + C(U); +}; + +template +C(U) -> C; + +template + requires true +using A = C; + +C ok(1); // ok, a is a C +A bad(2); // fails