Tested x86_64-pc-linux-gnu, applying to trunk.
-- 8< --
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 | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gcc/cp/constexpr.cc b/gcc/cp/constexpr.cc
index 6c6d2f3fa99..c5b7aa6685c 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. */
base-commit: 4491ee5688d0bcd69956af4126e9e4643d951178
--
2.54.0