@@ -655,6 +655,10 @@ get_nsdmi (tree member, bool in_ctor, tsubst_flags_t complain)
if (simple_target)
init = TARGET_EXPR_INITIAL (init);
init = break_out_target_exprs (init, /*loc*/true);
+ if (in_ctor && init && TREE_CODE (init) == TARGET_EXPR)
+ /* This expresses the full initialization, prevent perform_member_init from
+ calling another constructor (58162). */
+ TARGET_EXPR_DIRECT_INIT_P (init) = true;
if (simple_target && TREE_CODE (init) != CONSTRUCTOR)
/* Now put it back so C++17 copy elision works. */
init = get_target_expr (init);
@@ -1369,9 +1369,6 @@ digest_nsdmi_init (tree decl, tree init, tsubst_flags_t complain)
&& CP_AGGREGATE_TYPE_P (type))
init = reshape_init (type, init, complain);
init = digest_init_flags (type, init, flags, complain);
- if (TREE_CODE (init) == TARGET_EXPR)
- /* This represents the whole initialization. */
- TARGET_EXPR_DIRECT_INIT_P (init) = true;
return init;
}