From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1888) id 0E71D3858D28; Tue, 12 Apr 2022 16:59:24 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0E71D3858D28 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Patrick Palka To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-8110] c++: requires-expr in pack expansion using pack [PR103105] X-Act-Checkin: gcc X-Git-Author: Patrick Palka X-Git-Refname: refs/heads/master X-Git-Oldrev: 7c7e78e9c460991349065572e32cac49b20d0432 X-Git-Newrev: e2c7070ac7740508a7c49bfee9f895e216a272d6 Message-Id: <20220412165924.0E71D3858D28@sourceware.org> Date: Tue, 12 Apr 2022 16:59:24 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2022 16:59:24 -0000 https://gcc.gnu.org/g:e2c7070ac7740508a7c49bfee9f895e216a272d6 commit r12-8110-ge2c7070ac7740508a7c49bfee9f895e216a272d6 Author: Patrick Palka Date: Tue Apr 12 12:58:18 2022 -0400 c++: requires-expr in pack expansion using pack [PR103105] Here after dependent substitution of {Ts...} into the alias 'wrap', since we never partially instantiate a requires-expr, we end up with a requires-expr whose REQUIRES_EXPR_EXTRA_ARGS contains an ARGUMENT_PACK_SELECT (which just resolves to the parameter pack Ts). Then when hashing the resulting dependent specialization of A, we crash from iterative_hash_template_arg since it deliberately doesn't handle ARGUMENT_PACK_SELECT. Like in r12-7102-gdb5f1c17031ad8, it seems the right fix here is to resolve ARGUMENT_PACK_SELECT arguments before storing them into an extra args tree (such as REQUIRES_EXPR). PR c++/103105 gcc/cp/ChangeLog: * pt.cc (build_extra_args): Call preserve_args. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/concepts-requires29.C: New test. * g++.dg/cpp2a/concepts-requires29a.C: New test. Diff: --- gcc/cp/pt.cc | 2 +- gcc/testsuite/g++.dg/cpp2a/concepts-requires29.C | 18 ++++++++++++++++++ gcc/testsuite/g++.dg/cpp2a/concepts-requires29a.C | 23 +++++++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 78519562953..84712e6fc2f 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -13048,7 +13048,7 @@ build_extra_args (tree pattern, tree args, tsubst_flags_t complain) { /* Make a copy of the extra arguments so that they won't get changed out from under us. */ - tree extra = copy_template_args (args); + tree extra = preserve_args (copy_template_args (args), /*cow_p=*/false); if (local_specializations) if (tree locals = extract_local_specs (pattern, complain)) extra = tree_cons (NULL_TREE, extra, locals); diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires29.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires29.C new file mode 100644 index 00000000000..2cf69433d99 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires29.C @@ -0,0 +1,18 @@ +// PR c++/103105 +// { dg-do compile { target c++20 } } + +template struct A; + +template +using wrap = A<1 != (0 + ... + requires { Ts(); })>; + +template using type = wrap; + +using ty0 = type<>; +using ty0 = A; + +using ty1 = type; +using ty1 = A; + +using ty2 = type; +using ty2 = A; diff --git a/gcc/testsuite/g++.dg/cpp2a/concepts-requires29a.C b/gcc/testsuite/g++.dg/cpp2a/concepts-requires29a.C new file mode 100644 index 00000000000..84c226918f5 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp2a/concepts-requires29a.C @@ -0,0 +1,23 @@ +// PR c++/103105 +// { dg-do compile { target c++20 } } + +template struct list; + +template struct A; + +template +using wrap = A<1 != (0 + ... + requires { T() = Ts(); })>; + +template using type = list...>; + +using ty0 = type<>; +using ty0 = list<>; + +using ty1 = type; +using ty1 = list>; + +using ty2 = type; +using ty2 = list, A>; + +using ty3 = type; +using ty3 = list, A, A>;