From patchwork Thu Jan 14 13:21:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 1426373 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=gZEVoFhw; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DGlMC4xvtz9sVt for ; Fri, 15 Jan 2021 00:21:26 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F6933945C1A; Thu, 14 Jan 2021 13:21:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [IPv6:2607:f8b0:4864:20::72f]) by sourceware.org (Postfix) with ESMTPS id B059F3870891 for ; Thu, 14 Jan 2021 13:21:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org B059F3870891 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=nathanmsidwell@gmail.com Received: by mail-qk1-x72f.google.com with SMTP id 186so7641701qkj.3 for ; Thu, 14 Jan 2021 05:21:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:to:from:subject:message-id:date:user-agent:mime-version :content-language; bh=KKbJah37d8dH2Py0cyi+05KLn1ogWq3d5M/aOSM3Ocw=; b=gZEVoFhwb6JhSTg5aDhDQIB8s4u9Y5gjnTJOFqdgUoBTiuESSu1FlyxK34f2zYqWHH AwiycNnIISK4TxIDW200QxFIukuYhgt1jL3r2BOikStJaf3hEOOH6vFedGGFxk4G7onc p03ZKk0qRc+gT5O4qzXvFfGxAZfLydULEHq9MTtoa04yDv4G4e/b9a4GIHeH/DOyQU96 nSv7VVWds4Lp/HYO8/fPm5mRB97qcVBnVTX6FNz4o0VNiPQnYr7MNDgUuMYRadWqJpK9 +ZzIX6CE8NPwYVPF4WMU/2j1qBnoAkNSMWEBccvCqR7h2JFYHT53Z6TEVx4pc9vKYbw2 8XAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=KKbJah37d8dH2Py0cyi+05KLn1ogWq3d5M/aOSM3Ocw=; b=CNl77u5aM/oc7pvyy0n9l60s6w9yY+AB7/vJWCMjDxHDIfY7FjR6XWYRKkNfRnP4oc DqGMNVrwXVwWcYZ1TbDnOyvKv3R+RFW1CUMdE5pa+9/vLRkYEwKV6YGhIm7YKIe1MHY6 /l0v45Qd9vLxWdUgOMRKFOuzd/fFAkF07ct/gB0fBqrVuCqe38B+3WUITOlMF43TD6H9 INmF98ARBiDco1s+yMXKUKdSYFuupWLA+HGr24wTg5dG4uoK54OV+Bev0eAdF/CUOPm6 oww8kQy/gXfUU7EfzC3eDez1/54evenBrAEbrUkpVDag3rsCm/dTU9MnAOspUJasYV+Y Qspw== X-Gm-Message-State: AOAM5304Bx+EaXgzqsb2OtrwQP5l5G03TI6KeXOenbIoXIno2J7uMA4e YLZQUHe5LNdxrJlKxJl1lkg= X-Google-Smtp-Source: ABdhPJysRAD6OdDvnrhrgYFJOHq9hlcolGQCjzBPlgnAEMkh1x4Vu6q2p6sk30XE661JXKpMyg7GJw== X-Received: by 2002:a37:ccf:: with SMTP id 198mr6838462qkm.223.1610630482215; Thu, 14 Jan 2021 05:21:22 -0800 (PST) Received: from ?IPv6:2620:10d:c0a8:1102:94f0:c004:1b13:10bd? ([2620:10d:c091:480::1:b690]) by smtp.googlemail.com with ESMTPSA id r8sm2910974qkm.106.2021.01.14.05.21.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 14 Jan 2021 05:21:21 -0800 (PST) To: GCC Patches From: Nathan Sidwell Subject: c++: Fix erroneous parm comparison logic [PR 98372] Message-ID: <48114d39-2041-9aa4-d921-f65e17e9f9c5@acm.org> Date: Thu, 14 Jan 2021 08:21:20 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_EF, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" I flubbed an application of De Morgan's law. Let's just express the logic directly and let the compiler figure it out. This bug made it look like pr52830 was fixed, but it is not. PR c++/98372 gcc/cp/ * tree.c (cp_tree_equal): Correct map_context logic. gcc/testsuite/ * cpp0x/constexpr-52830.C: Restore dg-ice * g++.dg/template/pr98372.C: New. diff --git c/gcc/cp/tree.c w/gcc/cp/tree.c index d339036e88e..3a9a86de34a 100644 --- c/gcc/cp/tree.c +++ w/gcc/cp/tree.c @@ -3841,8 +3841,8 @@ cp_tree_equal (tree t1, tree t2) /* Module duplicate checking can have t1 = new, t2 = existing, and they should be considered matching at this point. */ - && (DECL_CONTEXT (t1) != map_context_from - && DECL_CONTEXT (t2) != map_context_to)) + && !(DECL_CONTEXT (t1) == map_context_from + && DECL_CONTEXT (t2) == map_context_to)) /* When comparing hash table entries, only an exact match is good enough; we don't want to replace 'this' with the version from another function. But be more flexible diff --git c/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C w/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C index 04f039fac43..2c9d2f9b329 100644 --- c/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C +++ w/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C @@ -1,5 +1,6 @@ // PR c++/52830 // { dg-do compile { target c++11 } } +// { dg-ice "comptypes" } template struct eif { typedef void type; }; template<> struct eif {}; diff --git c/gcc/testsuite/g++.dg/template/pr98372.C w/gcc/testsuite/g++.dg/template/pr98372.C new file mode 100644 index 00000000000..f1e8b0f3323 --- /dev/null +++ w/gcc/testsuite/g++.dg/template/pr98372.C @@ -0,0 +1,28 @@ +// PR 98372 ICE due to incorrect type compare +// { dg-do compile { target c++11 } } + +template using remove_pointer_t = typename _Tp ::type; +template struct enable_if; +template +using enable_if_t = typename enable_if<_Cond>::type; +template bool is_convertible_v; +template class Span; +template class Span { + using element_type = T; + template + Span(element_type (&arr)[N], + enable_if_t>, + decltype(nullptr)>); +}; +template class Span { + using element_type = T; + template + Span(element_type (&arr)[N], + enable_if_t>, + decltype(nullptr)>); +}; + +struct aaa +{ + Span data0; +};