On Tue, Jan 18, 2022 at 09:08:03AM -0500, Jason Merrill wrote: > > which makes call a TARGET_EXPR with the dtor in TARGET_EXPR_CLEANUP, > > but then call cxx_constant_value on it. In cxx_eval_outermost_constant_expr > > it triggers the: > > else if (TREE_CODE (t) != CONSTRUCTOR) > > { > > r = get_target_expr_sfinae (r, tf_warning_or_error | > > tf_no_cleanup); > > TREE_CONSTANT (r) = true; > > } > > which wraps the CONSTRUCTOR r into a new TARGET_EXPR, but one without > > dtors (I think we need e.g. the TREE_CONSTANT for the callers), > > and finally build_over_call uses that. > > Looks like you added the tf_no_cleanup in r10-3661 (constexpr new). Maybe > that should only be added if TARGET_EXPR_CLEANUP (t) is null?
I thought about that, but I'm worried that if the cleanup action is non-empty, then the TREE_CONSTANT (r) = true; after it isn't appropriate, because the TARGET_EXPR has side-effects. And the callers like cxx_constant_value_sfinae just return error_mark_node if it isn't set: if (sfinae && !TREE_CONSTANT (r)) r = error_mark_node; Jakub