]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
c++: another constexpr empty class tweak
authorJason Merrill <jason@redhat.com>
Tue, 19 May 2026 09:15:00 +0000 (05:15 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 21 May 2026 20:15:34 +0000 (16:15 -0400)
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.

gcc/cp/constexpr.cc

index 6c6d2f3fa9943edb3fd5c2a594087c83df1eb0b0..c5b7aa6685c54c596666e68645db2d7c0163a179 100644 (file)
@@ -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.  */