From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <gentoo-commits+bounces-1699694-garchives=archives.gentoo.org@lists.gentoo.org> Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 72F981581F0 for <garchives@archives.gentoo.org>; Fri, 13 Dec 2024 05:08:56 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id ADF87E0940; Fri, 13 Dec 2024 05:08:55 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 90BC5E0940 for <gentoo-commits@lists.gentoo.org>; Fri, 13 Dec 2024 05:08:55 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 73B40341465 for <gentoo-commits@lists.gentoo.org>; Fri, 13 Dec 2024 05:08:54 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id ACD1B161D for <gentoo-commits@lists.gentoo.org>; Fri, 13 Dec 2024 05:08:52 +0000 (UTC) From: "Sam James" <sam@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" <sam@gentoo.org> Message-ID: <1734066510.9af17f2c6db4433f71d81aed95fca9a95780bb25.sam@gentoo> Subject: [gentoo-commits] proj/gcc-patches:master commit in: 15.0.0/gentoo/ X-VCS-Repository: proj/gcc-patches X-VCS-Files: 15.0.0/gentoo/77_all_PR117980-ICE-cxx_eval_outermost_constant_expr.patch X-VCS-Directories: 15.0.0/gentoo/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 9af17f2c6db4433f71d81aed95fca9a95780bb25 X-VCS-Branch: master Date: Fri, 13 Dec 2024 05:08:52 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 55c8f7f0-213c-4e8b-8f00-9b0220ee53f1 X-Archives-Hash: 7a21d44334c5553eb4c4f527eccc02d6 commit: 9af17f2c6db4433f71d81aed95fca9a95780bb25 Author: Sam James <sam <AT> gentoo <DOT> org> AuthorDate: Fri Dec 13 05:08:30 2024 +0000 Commit: Sam James <sam <AT> gentoo <DOT> org> CommitDate: Fri Dec 13 05:08:30 2024 +0000 URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=9af17f2c 15.0.0: update C++ ICE patch The actual fix is the same but it adds testcases and a commit message, so let's sync up. Signed-off-by: Sam James <sam <AT> gentoo.org> ...7980-ICE-cxx_eval_outermost_constant_expr.patch | 120 ++++++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/15.0.0/gentoo/77_all_PR117980-ICE-cxx_eval_outermost_constant_expr.patch b/15.0.0/gentoo/77_all_PR117980-ICE-cxx_eval_outermost_constant_expr.patch index 1252fc2..f077536 100644 --- a/15.0.0/gentoo/77_all_PR117980-ICE-cxx_eval_outermost_constant_expr.patch +++ b/15.0.0/gentoo/77_all_PR117980-ICE-cxx_eval_outermost_constant_expr.patch @@ -1,4 +1,64 @@ -https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117980#c7 +https://inbox.sourceware.org/gcc-patches/20241212184222.471783-1-polacek@redhat.com/ + +From f9ec39fcb8905fad2aba87bf328f0d5934b2385d Mon Sep 17 00:00:00 2001 +Message-ID: <f9ec39fcb8905fad2aba87bf328f0d5934b2385d.1734066473.git.sam@gentoo.org> +From: Marek Polacek <polacek@redhat.com> +Date: Thu, 12 Dec 2024 13:42:22 -0500 +Subject: [PATCH] c++: ICE in TARGET_EXPR evaluation in cp_fold_r [PR117980] + +This ICE started with the recent prvalue optimization (r15-6052). In +cp_fold_r we have: + + if (tree &init = TARGET_EXPR_INITIAL (stmt)) + { + cp_walk_tree (&init, cp_fold_r, data, NULL); + // ... + tree folded = maybe_constant_init (init, TARGET_EXPR_SLOT (stmt)); + +What can happen here is that originally the TARGET_EXPR is: + + TARGET_EXPR <D.2747, <<< Unknown tree: aggr_init_expr + 5 + __ct_comp + D.2747 + (struct subrange *) <<< Unknown tree: void_cst >>> + &TARGET_EXPR <D.2707, {.it=TARGET_EXPR <D.2695, ...>}> >>>> + +but after the first cp_walk_tree we fold the D.2707 TARGET_EXPR into: + + TARGET_EXPR <D.2707, <<< Unknown tree: expr_stmt + D.2707.it = TARGET_EXPR <D.2695, ...> >>>> + +and then we pass the EXPR_STMT to maybe_constant_init, with D.2707 as +the object. But their types don't match anymore, so we crash. We'd +have to pass D.2707.it as the object for it to work. + +But I don't think we need to pass any object to maybe_constant_init; +it'll grab the appropriate one itself. + +constexpr-prvalue3.C is reduced from a large std::ranges libstdc++ test. + + PR c++/117980 + +gcc/cp/ChangeLog: + + * cp-gimplify.cc (cp_fold_r) <case TARGET_EXPR>: Don't pass an object + to maybe_constant_init. + +gcc/testsuite/ChangeLog: + +* g++.dg/cpp0x/constexpr-prvalue2.C: New test. + * g++.dg/cpp0x/constexpr-prvalue3.C: New test. +--- + gcc/cp/cp-gimplify.cc | 2 +- + .../g++.dg/cpp0x/constexpr-prvalue2.C | 15 +++++++++++ + .../g++.dg/cpp0x/constexpr-prvalue3.C | 26 +++++++++++++++++++ + 3 files changed, 42 insertions(+), 1 deletion(-) + create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-prvalue2.C + create mode 100644 gcc/testsuite/g++.dg/cpp0x/constexpr-prvalue3.C + +diff --git a/gcc/cp/cp-gimplify.cc b/gcc/cp/cp-gimplify.cc +index 623e2ee6e964..a861331c7c7d 100644 --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -1477,7 +1477,7 @@ cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_) @@ -10,3 +70,61 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117980#c7 if (folded != init && TREE_CONSTANT (folded)) init = folded; } +diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-prvalue2.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-prvalue2.C +new file mode 100644 +index 000000000000..46053231cf83 +--- /dev/null ++++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-prvalue2.C +@@ -0,0 +1,15 @@ ++// PR c++/117980 ++// { dg-do compile { target c++11 } } ++// { dg-options "-O" } ++ ++struct S { ++ constexpr S(S &); // { dg-warning "used but never defined" } ++ ~S(); ++}; ++struct B { ++ S s; ++}; ++struct A { ++ B b; ++}; ++void fn(B b) { A{b}; } +diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-prvalue3.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-prvalue3.C +new file mode 100644 +index 000000000000..a2eb12c02d74 +--- /dev/null ++++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-prvalue3.C +@@ -0,0 +1,26 @@ ++// PR c++/117980 ++// { dg-do compile { target c++11 } } ++// { dg-options "-O" } ++ ++struct _Safe_iterator { ++ _Safe_iterator(); ++ ~_Safe_iterator(); ++}; ++template <typename _Tp> ++struct vector { ++ vector(int) {} ++ constexpr _Safe_iterator end() { ++ return _Safe_iterator(); ++ } ++}; ++template <typename It> struct sentinel { ++ It it; ++}; ++template <typename _Sent> ++struct subrange { ++ subrange(sentinel<_Safe_iterator>) {} ++}; ++void test01() { ++ vector<int> v{0}; ++ subrange<sentinel<_Safe_iterator>>{sentinel<_Safe_iterator>{v.end()}}; ++} + +base-commit: d136fa00f0d5faff8397edcd7e4ebb3445ab21b0 +-- +2.47.1 +