aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/constexpr.cc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2024-02-01 17:23:53 -0500
committerJason Merrill <jason@redhat.com>2024-02-01 22:22:06 -0500
commitf4998609908e4926fc095ce97cb84b187294fd1d (patch)
treedbb5fc97845831fc32c5fbe38da794a9d77a340f /gcc/cp/constexpr.cc
parent0b786ff38ab398087820d91241e030a28c451df9 (diff)
downloadgcc-f4998609908e4926fc095ce97cb84b187294fd1d.zip
gcc-f4998609908e4926fc095ce97cb84b187294fd1d.tar.gz
gcc-f4998609908e4926fc095ce97cb84b187294fd1d.tar.bz2
c++: no_unique_address and constexpr [PR112439]
Here, because we don't build a CONSTRUCTOR for an empty base, we were wrongly marking the Foo CONSTRUCTOR as complete after initializing the Empty member. Fixed by checking empty_base here as well. PR c++/112439 gcc/cp/ChangeLog: * constexpr.cc (cxx_eval_store_expression): Check empty_base before marking a CONSTRUCTOR readonly. gcc/testsuite/ChangeLog: * g++.dg/cpp2a/no_unique_address15.C: New test.
Diffstat (limited to 'gcc/cp/constexpr.cc')
-rw-r--r--gcc/cp/constexpr.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 6350fe154..2ebb147 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -6694,6 +6694,7 @@ cxx_eval_store_expression (const constexpr_ctx *ctx, tree t,
object. Make a note of this fact by marking the CONSTRUCTOR
TREE_READONLY. */
if (TREE_CODE (t) == INIT_EXPR
+ && !empty_base
&& TREE_CODE (*valp) == CONSTRUCTOR
&& TYPE_READONLY (type))
{