https://gcc.gnu.org/g:392f10be00ec19d1660d5f56edb26dc7aeb22586

commit r17-654-g392f10be00ec19d1660d5f56edb26dc7aeb22586
Author: Jason Merrill <[email protected]>
Date:   Tue May 19 05:15:00 2026 -0400

    c++: another constexpr empty class tweak
    
    While talking about PR125336, I noticed that we were unnecessarily omitting
    a subobject CONSTRUCTOR for non-potentially-overlapping fields of empty
    class type.  Let's check is_empty_field instead.
    
    gcc/cp/ChangeLog:
    
            * constexpr.cc (init_subob_ctx): Check is_empty_field.

Diff:
---
 gcc/cp/constexpr.cc | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 6c6d2f3fa994..c5b7aa6685c5 100644
--- a/gcc/cp/constexpr.cc
+++ b/gcc/cp/constexpr.cc
@@ -6721,7 +6721,7 @@ init_subob_ctx (const constexpr_ctx *ctx, constexpr_ctx 
&new_ctx,
     {
       /* This can happen if the enclosing object is also an empty subobject
         (c++/125315).  */
-      gcc_checking_assert (is_empty_class (type));
+      gcc_checking_assert (is_empty_field (index));
       return;
     }
 
@@ -6745,7 +6745,7 @@ 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)
+  if (is_empty_field (index)
       && 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.  */

Reply via email to