From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id E742A3858C56 for ; Tue, 12 Apr 2022 20:14:54 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E742A3858C56 Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-518-WrGzSDkVPLOMMzO3kVtdnQ-1; Tue, 12 Apr 2022 16:14:53 -0400 X-MC-Unique: WrGzSDkVPLOMMzO3kVtdnQ-1 Received: by mail-qv1-f71.google.com with SMTP id a3-20020a056214062300b00443cd6175c8so40190qvx.4 for ; Tue, 12 Apr 2022 13:14:53 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=XI2hP357dREXnifV7VxNORBTVMHM3An13ymojuYrriU=; b=IfFc45e+EhdlFWIY4bOGgVY/BAZaSFXGmYCON2QCO9fsN9EoydgCGU6EtP0ovAqWhX HJ5J4ZnlM4VSvrBXLw+zbqH36zOpquZT7C274MpP+JTyzvMh8vKu5G4driGggxJVAizV 3wKVqsQyGSjHQSkqOclhvSdDexFGmDNMfaCk1tnwBwq8JXdHZHrHaTljG/MwNXMSlU3m 08giJdKkwZwtY6z5g/zBh1w4oLZsL5cIn5MY2BrIE2iNGfQ5E8MN2w7TZyb9przuOcRu CNNX3oRoq67mkOrWDRiJgELgEf2XNmsJ//7K9bUJiX1j6MJ7p209afEfLlawSv2pMvL+ Z+2Q== X-Gm-Message-State: AOAM533htJx73CrfkE201+Cp5lI196XdX7tbfSd2TrXpukTza7wR1DZt p3TSCbh4JzcMG6aXziZEPeg10RQ7THLf8v4GFpPn9qWsVOz/LbZ4hWM3jKWUhjwfIdZweZyI+F2 W2KctvKFMvnzdRArKFA== X-Received: by 2002:a05:6214:1d0e:b0:445:5f77:e292 with SMTP id e14-20020a0562141d0e00b004455f77e292mr3388500qvd.79.1649794492987; Tue, 12 Apr 2022 13:14:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIa33iN2Xdh+tC8wxV/Ot/3jgIWIZBPj6JlTecxINI9FR1RTsIfgjYCpPIAlBylYbBpScYOA== X-Received: by 2002:a05:6214:1d0e:b0:445:5f77:e292 with SMTP id e14-20020a0562141d0e00b004455f77e292mr3388476qvd.79.1649794492649; Tue, 12 Apr 2022 13:14:52 -0700 (PDT) Received: from [192.168.1.149] (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id n16-20020ac85b50000000b002eded22d625sm6010496qtw.87.2022.04.12.13.14.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Apr 2022 13:14:51 -0700 (PDT) Message-ID: <1c62bc70-6b4c-2eed-52ba-bc79234e8c22@redhat.com> Date: Tue, 12 Apr 2022 16:14:49 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.0 Subject: Re: [PATCH] c++: requires-expr in pack expansion using pack [PR103105] To: Patrick Palka Cc: GCC Patches References: <20220412161755.2948239-1-ppalka@redhat.com> <035540e1-233a-ae65-648e-fbb50efed24d@redhat.com> From: Jason Merrill In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-13.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Apr 2022 20:14:56 -0000 On 4/12/22 14:44, Patrick Palka wrote: > On Tue, Apr 12, 2022 at 12:33 PM Jason Merrill wrote: >> >> On 4/12/22 12:17, Patrick Palka wrote: >>> 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 looking up the resulting dependent specialization of A, we >>> crash from iterative_hash_template_arg since it deliberately doesn't >>> handle ARGUMENT_PACK_SELECT. >>> >>> Like with 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). >>> >>> Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for >>> trunk/11? For 11, we'd need to backport r12-7102 as a prereq. >> >> OK, that additional backport seems reasonable. > > Thanks a lot, committed to trunk so far. I attempted backporting this > (along with the mentioned prereq r12-7102) but it seems we also need > to backport your r12-7857-gfc50d9a252c89c (from PR104008) before we > begin to accept the second testcase. (Now I remember why I sat on > this PR for so long :)) It's in now. >> >> >>> PR c++/103105 >>> PR c++/103706 >>> >>> 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. >>> --- >>> gcc/cp/pt.cc | 2 +- >>> .../g++.dg/cpp2a/concepts-requires29.C | 18 +++++++++++++++ >>> .../g++.dg/cpp2a/concepts-requires29a.C | 23 +++++++++++++++++++ >>> 3 files changed, 42 insertions(+), 1 deletion(-) >>> create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-requires29.C >>> create mode 100644 gcc/testsuite/g++.dg/cpp2a/concepts-requires29a.C >>> >>> 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..5118df978c9 >>> --- /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 class 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..c41c1e6d039 >>> --- /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>; >> >