From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1059) id BF5AE3851C20; Thu, 14 Jan 2021 13:31:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BF5AE3851C20 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Nathan Sidwell To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-6666] c++: Fix erroneous parm comparison logic [PR 98372] X-Act-Checkin: gcc X-Git-Author: Nathan Sidwell X-Git-Refname: refs/heads/master X-Git-Oldrev: 08a4adcf2b6ded2fea97195c715757df61a23395 X-Git-Newrev: d61d2a5f3ce9238bad7cbd7733d90c6ec7ae5fbc Message-Id: <20210114133113.BF5AE3851C20@sourceware.org> Date: Thu, 14 Jan 2021 13:31:13 +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: Thu, 14 Jan 2021 13:31:13 -0000 https://gcc.gnu.org/g:d61d2a5f3ce9238bad7cbd7733d90c6ec7ae5fbc commit r11-6666-gd61d2a5f3ce9238bad7cbd7733d90c6ec7ae5fbc Author: Nathan Sidwell Date: Thu Jan 14 05:15:33 2021 -0800 c++: Fix erroneous parm comparison logic [PR 98372] 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/ * g++.dg/cpp0x/constexpr-52830.C: Restore dg-ice * g++.dg/template/pr98372.C: New. Diff: --- gcc/cp/tree.c | 4 ++-- gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C | 1 + gcc/testsuite/g++.dg/template/pr98372.C | 28 ++++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d339036e88e..3a9a86de34a 100644 --- a/gcc/cp/tree.c +++ b/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 a/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C index 04f039fac43..2c9d2f9b329 100644 --- a/gcc/testsuite/g++.dg/cpp0x/constexpr-52830.C +++ b/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 a/gcc/testsuite/g++.dg/template/pr98372.C b/gcc/testsuite/g++.dg/template/pr98372.C new file mode 100644 index 00000000000..f1e8b0f3323 --- /dev/null +++ b/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; +};