@@ -4777,12 +4777,9 @@ cxx_eval_bare_aggregate (const constexpr_ctx *ctx, tree t,
tree orig_value = value;
/* Like in cxx_eval_store_expression, omit entries for empty fields. */
bool no_slot = TREE_CODE (type) == RECORD_TYPE && is_empty_field (index);
- if (no_slot)
- new_ctx = *ctx;
- else
- init_subob_ctx (ctx, new_ctx, index, value);
+ init_subob_ctx (ctx, new_ctx, index, value);
int pos_hint = -1;
- if (new_ctx.ctor != ctx->ctor)
+ if (new_ctx.ctor != ctx->ctor && !no_slot)
{
/* If we built a new CONSTRUCTOR, attach it now so that other
initializers can refer to it. */
new file mode 100644
@@ -0,0 +1,27 @@
+// PR c++/105795
+// { dg-do compile { target c++17 } }
+
+struct empty
+{};
+
+template <typename T>
+struct tuple_holder
+{
+ [[no_unique_address]] T value;
+};
+
+struct tuple : tuple_holder<int>, tuple_holder<empty>
+{};
+
+constexpr auto make_tuple(int&& i, empty&& e)
+{
+ return tuple{i, e};
+}
+
+constexpr int foo()
+{
+ auto tuple = make_tuple(1, empty{});
+ return static_cast<const tuple_holder<int>&>(tuple).value;
+}
+
+static_assert (foo() == 1);