From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 6129415812D for ; Mon, 06 Jan 2025 04:13:59 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 96BC1E078A; Mon, 06 Jan 2025 04:13:58 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 pigeon.gentoo.org (Postfix) with ESMTPS id 7F93BE078A for ; Mon, 06 Jan 2025 04:13:58 +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) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id B117D33BEE9 for ; Mon, 06 Jan 2025 04:13:57 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 1B499AED for ; Mon, 06 Jan 2025 04:13:56 +0000 (UTC) From: "Sam James" 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" Message-ID: <1736136628.3b46d9416aa28317356af1934a469511433d48c1.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/81_all_PR118199-c-Clear-TARGET_EXPR_ELIDING_P-when-forced-to-use-a-c.patch 15.0.0/gentoo/README.history X-VCS-Directories: 15.0.0/gentoo/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 3b46d9416aa28317356af1934a469511433d48c1 X-VCS-Branch: master Date: Mon, 06 Jan 2025 04:13:56 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 4d43e9f5-2c93-4417-8144-55b01004467e X-Archives-Hash: 54222877e2d4e9832646c2a36359f931 commit: 3b46d9416aa28317356af1934a469511433d48c1 Author: Sam James gentoo org> AuthorDate: Mon Jan 6 04:10:28 2025 +0000 Commit: Sam James gentoo org> CommitDate: Mon Jan 6 04:10:28 2025 +0000 URL: https://gitweb.gentoo.org/proj/gcc-patches.git/commit/?id=3b46d941 15.0.0: fix crash with -fno-elide-constructors Bug: https://gcc.gnu.org/PR118199 Signed-off-by: Sam James gentoo.org> ...GET_EXPR_ELIDING_P-when-forced-to-use-a-c.patch | 92 ++++++++++++++++++++++ 15.0.0/gentoo/README.history | 1 + 2 files changed, 93 insertions(+) diff --git a/15.0.0/gentoo/81_all_PR118199-c-Clear-TARGET_EXPR_ELIDING_P-when-forced-to-use-a-c.patch b/15.0.0/gentoo/81_all_PR118199-c-Clear-TARGET_EXPR_ELIDING_P-when-forced-to-use-a-c.patch new file mode 100644 index 0000000..a50765c --- /dev/null +++ b/15.0.0/gentoo/81_all_PR118199-c-Clear-TARGET_EXPR_ELIDING_P-when-forced-to-use-a-c.patch @@ -0,0 +1,92 @@ +From 403c57a863a48014db8124cfe84cfbfd8001c084 Mon Sep 17 00:00:00 2001 +Message-ID: <403c57a863a48014db8124cfe84cfbfd8001c084.1736136592.git.sam@gentoo.org> +From: Simon Martin +Date: Sun, 5 Jan 2025 20:01:26 +0000 +Subject: [PATCH] c++: Clear TARGET_EXPR_ELIDING_P when forced to use a copy + constructor due to __no_unique_address__ [PR118199] + +We currently fail with a checking assert upon the following valid code +when using -fno-elide-constructors + +=== cut here === +struct d { ~d(); }; +d &b(); +struct f { + [[__no_unique_address__]] d e; +}; +struct h : f { + h() : f{b()} {} +} i; +=== cut here === + +The problem is that split_nonconstant_init_1 detects that it cannot +elide the copy constructor due to __no_unique_address__ but does not +clear TARGET_EXPR_ELIDING_P, and due to -fno-elide-constructors, we trip +on a checking assert in cp_gimplify_expr. + +This patch fixes this by making sure that we clear TARGET_EXPR_ELIDING_P +if we determine that we have to keep the copy constructor due to +__no_unique_address__. An alternative would be to just check for +elide_constructors in that assert, but I think it'd lose most of its +value if we did so. + +Successfully tested on x86_64-pc-linux-gnu. + + PR c++/118199 + +gcc/cp/ChangeLog: + + * typeck2.cc (split_nonconstant_init_1): Clear + TARGET_EXPR_ELIDING_P if we need to use a copy constructor + because of __no_unique_address__. + +gcc/testsuite/ChangeLog: + +* g++.dg/init/no-elide3.C: New test. +--- + gcc/cp/typeck2.cc | 5 +++++ + gcc/testsuite/g++.dg/init/no-elide3.C | 12 ++++++++++++ + 2 files changed, 17 insertions(+) + create mode 100644 gcc/testsuite/g++.dg/init/no-elide3.C + +diff --git a/gcc/cp/typeck2.cc b/gcc/cp/typeck2.cc +index 381f198d0fe6..f50c5f767bb8 100644 +--- a/gcc/cp/typeck2.cc ++++ b/gcc/cp/typeck2.cc +@@ -655,6 +655,11 @@ split_nonconstant_init_1 (tree dest, tree init, bool last, + && make_safe_copy_elision (sub, value)) + goto build_init; + ++ if (TREE_CODE (value) == TARGET_EXPR) ++ /* We have to add this constructor, so we will not ++ elide. */ ++ TARGET_EXPR_ELIDING_P (value) = false; ++ + tree name = (DECL_FIELD_IS_BASE (field_index) + ? base_ctor_identifier + : complete_ctor_identifier); +diff --git a/gcc/testsuite/g++.dg/init/no-elide3.C b/gcc/testsuite/g++.dg/init/no-elide3.C +new file mode 100644 +index 000000000000..659eb19bc95a +--- /dev/null ++++ b/gcc/testsuite/g++.dg/init/no-elide3.C +@@ -0,0 +1,12 @@ ++// PR c++/118199 ++// { dg-do "compile" { target c++11 } } ++// { dg-options "-fno-elide-constructors" } ++ ++struct d { ~d(); }; ++d &b(); ++struct f { ++ [[__no_unique_address__]] d e; ++}; ++struct h : f { ++ h() : f{b()} {} ++} i; + +base-commit: 451ff5b58f7c5958f8341160343680262944a63f +prerequisite-patch-id: cca034489e37f362f6ff4ff1aba0258270153a6a +prerequisite-patch-id: dcb0315887787c40fae21980c53d20d0b6e234b7 +-- +2.47.1 + diff --git a/15.0.0/gentoo/README.history b/15.0.0/gentoo/README.history index bc29883..b49ecdf 100644 --- a/15.0.0/gentoo/README.history +++ b/15.0.0/gentoo/README.history @@ -1,6 +1,7 @@ 37 ???? + 80_all_PR81358-Enable-automatic-linking-of-libatomic.patch + + 81_all_PR118199-c-Clear-TARGET_EXPR_ELIDING_P-when-forced-to-use-a-c.patch 36 5 January 2025