From patchwork Fri Oct 1 13:46:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 45680 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2B1743857C7E for ; Fri, 1 Oct 2021 13:47:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2B1743857C7E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1633096037; bh=vDG/Sf69ZsgIYokOyC9gsJXtgEws57ruP6BlF8SHf08=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=ckQ+6EJhhgYjstGu9DDmWvh9rmebIOMR/UNKnIcwVJoQku+XjUBpg0MBu2cDEnBPV owR6FD4rAZ8DKU4CX5uWmRQ97TY5MkDUM5A0WCHhZOypB27MwcId+AOa0p+jaKueOQ bMwAy6Lo1AYd/MqYhLRMKpphiHLwCtc0m+HInEgM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id 0C7093858C2C for ; Fri, 1 Oct 2021 13:46:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0C7093858C2C Received: from mail-qv1-f71.google.com (mail-qv1-f71.google.com [209.85.219.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-318-GUqQamEhOSSv6VsWUXBWCA-1; Fri, 01 Oct 2021 09:46:47 -0400 X-MC-Unique: GUqQamEhOSSv6VsWUXBWCA-1 Received: by mail-qv1-f71.google.com with SMTP id h25-20020a0cab19000000b0037a49d15c93so13191088qvb.22 for ; Fri, 01 Oct 2021 06:46:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vDG/Sf69ZsgIYokOyC9gsJXtgEws57ruP6BlF8SHf08=; b=BfbwE89A8QqR8ERitlt7rXfuGKXD9/Ws4TZiN/ZbNKknCJAmob/1SM7txjHUC3UsnX GhjF4qqj51kaeXddRyCjhEwAx9kzLgI+qbcayREARTYqCREUtr2Y8XjI0/ySKisiUg2/ fVNRizmMrY2MCeNWD+wn4gHBuZuml1UiF+6o2HvyKQSETEdZcIQXKOaFi0sFSB+oqpcV 9WUTlxXLg4gr2QBZCIrjZpdXlGL/v9IqIoc9Xxm4ToRotKIYrgGpECl0lA4iMTeTVWOC eIgsWIG/dbA4X2QnbkSMKSYWr5TJzr2zr2vwFob02+bZc991rgjtbcS6C6zuZeZ5Ffpu bvgg== X-Gm-Message-State: AOAM532Q7U9AEk+0vvE6Bkf9qkIwnXRWRxo9sUfjZAQIk5mDCAdul95s QssjbIZJPKvZKs5pmQ4IUoL+s1Gz6uFmBx64KbSZPnrHdQ69QxbWg0d8LQVXYOdwZine5m/JBo/ G13hMeul7iPrHCqK5/PIpIH1vQ+geGiEO7g53ogzJEUnmOzh98lNbe20T7OmsEtq4iBE= X-Received: by 2002:ac8:764a:: with SMTP id i10mr13050461qtr.206.1633096006101; Fri, 01 Oct 2021 06:46:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxjF9fWHp2n/tpriG7pDrz/l3Ys/4BXV+0BTtlUEnwNF0ftHYWXRhK9ekZNprkZ/YwVgtq9PQ== X-Received: by 2002:ac8:764a:: with SMTP id i10mr13050420qtr.206.1633096005753; Fri, 01 Oct 2021 06:46:45 -0700 (PDT) Received: from localhost.localdomain (ool-457d493a.dyn.optonline.net. [69.125.73.58]) by smtp.gmail.com with ESMTPSA id i11sm2763429qki.28.2021.10.01.06.46.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Oct 2021 06:46:45 -0700 (PDT) To: gcc-patches@gcc.gnu.org Subject: [PATCH] c++: unifying equal NONTYPE_ARGUMENT_PACKs [PR102547] Date: Fri, 1 Oct 2021 09:46:43 -0400 Message-Id: <20211001134643.1941700-1-ppalka@redhat.com> X-Mailer: git-send-email 2.33.0.610.gcefe983a32 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-15.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP 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-Patchwork-Original-From: Patrick Palka via Gcc-patches From: Patrick Palka Reply-To: Patrick Palka Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Here during partial ordering of the two partial specializations we end up in unify with parm=arg=NONTYPE_ARGUMENT_PACK, and crash shortly thereafter because uses_template_parms calls potential_constant_expression which doesn't handle NONTYPE_ARGUMENT_PACK. This patch fixes this by checking dependent_template_arg_p instead of uses_template_parms when parm==arg, which does handle NONTYPE_ARGUMENT_PACK. We could also perhaps fix uses_template_parms / inst_dep_expr_p to better handle NONTYPE_ARGUMENT_PACK, but interestingly none of our existing tests exercise calling those functions on NONTYPE_ARGUMENT_PACK, so such a fix would be seemingly moot. Bootstrapped and regtested on x86_64-pc-linux-gnu, does this look OK for trunk/11? PR c++/102547 gcc/cp/ChangeLog: * pt.c (unify): Check dependent_template_arg_p instead of uses_template_parms when parm==arg. gcc/testsuite/ChangeLog: * g++.dg/cpp0x/variadic-partial2.C: New test. --- gcc/cp/pt.c | 2 +- .../g++.dg/cpp0x/variadic-partial2.C | 16 ++++++++++++++ .../g++.dg/cpp0x/variadic-partial2a.C | 22 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C create mode 100644 gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 1dcdffe322a..59c00c77a30 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -23587,7 +23587,7 @@ unify (tree tparms, tree targs, tree parm, tree arg, int strict, even if ARG == PARM, since we won't record unifications for the template parameters. We might need them if we're trying to figure out which of two things is more specialized. */ - if (arg == parm && !uses_template_parms (parm)) + if (arg == parm && !dependent_template_arg_p (parm)) return unify_success (explain_p); /* Handle init lists early, so the rest of the function can assume diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C new file mode 100644 index 00000000000..df61f26a3c1 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2.C @@ -0,0 +1,16 @@ +// PR c++/102547 +// { dg-do compile { target c++11 } } + +template +struct vals { }; + +template +struct vals_client { }; + +template +struct vals_client, T> { }; + +template +struct vals_client, void> { }; + +template struct vals_client, void>; //- "sorry, unimplemented..., ICE" diff --git a/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C new file mode 100644 index 00000000000..cc0ea488ad3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/variadic-partial2a.C @@ -0,0 +1,22 @@ +// PR c++/102547 +// { dg-do compile { target c++11 } } +// A version of variadic-partial2.C where the partial ordering is performed +// on function templates instead of class templates. + +template +struct vals { }; + +template +void f(V, T) { }; + +template +void f(vals, T) { }; + +template +void f(vals, char) { }; + +template void f(vals<1, 2>, char); //- "sorry, unimplemented..., ICE" + +int main() { + f(vals<1, 3>{}, 'a'); //- "sorry, unimplemented..., ICE" +}