On 6/5/26 6:50 AM, Richard Biener via Gcc wrote:
Status
======

The gcc-15 branch is now frozen for release, all changes require
release manager approval.

I'd like to apply this reversion:

From 90bff22560c7b64ed846bacbfa946866125bd51c Mon Sep 17 00:00:00 2001
From: Jason Merrill <[email protected]>
Date: Fri, 5 Jun 2026 08:58:25 -0400
Subject: [PATCH] Revert "c++: fix constexpr union with empty member
 [PR123346]"
To: [email protected]

Revert "c++: constexpr nested empty objects [PR125315]"
This reverts commit 92f35736ebf9c6d24622e129c5ebac71bafcedd5.
This reverts commit 38228ed4281a2a3beb0ac920085861cd300c1d6f.

These changes needed too much follow-on work to feel safe for 15.3/14.4.
---
 gcc/cp/constexpr.cc                           | 23 ++++---------------
 .../g++.dg/cpp2a/constexpr-union10.C          |  8 -------
 .../g++.dg/cpp2a/no_unique_address16.C        | 10 --------
 3 files changed, 4 insertions(+), 37 deletions(-)
 delete mode 100644 gcc/testsuite/g++.dg/cpp2a/constexpr-union10.C
 delete mode 100644 gcc/testsuite/g++.dg/cpp2a/no_unique_address16.C

diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 59c1b31fa0b..5adcf0a715b 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -5432,22 +5432,8 @@ init_subob_ctx (const constexpr_ctx *ctx, constexpr_ctx &new_ctx,
   if (!AGGREGATE_TYPE_P (type) && !VECTOR_TYPE_P (type))
     /* A non-aggregate member doesn't get its own CONSTRUCTOR.  */
     return;
-
-  tree ctxtype = NULL_TREE;
-  if (ctx->ctor)
-    ctxtype = TREE_TYPE (ctx->ctor);
-  else if (ctx->object)
-    ctxtype = TREE_TYPE (ctx->object);
-  else
-    {
-      /* This can happen if the enclosing object is also an empty subobject
-	 (c++/125315).  */
-      gcc_checking_assert (is_empty_class (type));
-      return;
-    }
-
   if (VECTOR_TYPE_P (type)
-      && VECTOR_TYPE_P (ctxtype)
+      && VECTOR_TYPE_P (TREE_TYPE (ctx->ctor))
       && index == NULL_TREE)
     /* A vector inside of a vector CONSTRUCTOR, e.g. when a larger
        vector is constructed from smaller vectors, doesn't get its own
@@ -5466,10 +5452,9 @@ init_subob_ctx (const constexpr_ctx *ctx, constexpr_ctx &new_ctx,
 	new_ctx.object = build_ctor_subob_ref (index, type, ctx->object);
     }
 
-  if (is_empty_class (type)
-      && TREE_CODE (ctxtype) != UNION_TYPE)
-    /* Leave ctor null for an empty subobject of a non-union class, they aren't
-       represented in the result of evaluation.  */
+  if (is_empty_class (type))
+    /* Leave ctor null for an empty subobject, they aren't represented in the
+       result of evaluation.  */
     new_ctx.ctor = NULL_TREE;
   else
     {
diff --git a/gcc/testsuite/g++.dg/cpp2a/constexpr-union10.C b/gcc/testsuite/g++.dg/cpp2a/constexpr-union10.C
deleted file mode 100644
index 36b0fe8fa1b..00000000000
--- a/gcc/testsuite/g++.dg/cpp2a/constexpr-union10.C
+++ /dev/null
@@ -1,8 +0,0 @@
-// PR c++/123346
-// { dg-do compile { target c++20 } }
-struct Unit {};
-union Union { Unit unit; };
-constexpr Union make(Union&& other) {
-    return Union {.unit = other.unit };
-}
-constexpr Union u = make(Union { .unit = Unit{} });
diff --git a/gcc/testsuite/g++.dg/cpp2a/no_unique_address16.C b/gcc/testsuite/g++.dg/cpp2a/no_unique_address16.C
deleted file mode 100644
index 22c0b699f92..00000000000
--- a/gcc/testsuite/g++.dg/cpp2a/no_unique_address16.C
+++ /dev/null
@@ -1,10 +0,0 @@
-// PR c++/125315
-// { dg-do compile { target c++20 } }
-// { dg-prune-output "used but never defined" }
-
-struct S{~S(){}};
-constexpr S& f(S& t);
-struct W{[[no_unique_address]]S v;};
-struct R:W{};
-S s;
-auto x=R{{f(s)}};
-- 
2.54.0

Reply via email to