https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118396
Marek Polacek <mpolacek at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #11 from Marek Polacek <mpolacek at gcc dot gnu.org> --- One idea would be to only fold simple TARGET_EXPR's initializer: --- a/gcc/cp/cp-gimplify.cc +++ b/gcc/cp/cp-gimplify.cc @@ -1475,7 +1475,7 @@ cp_fold_r (tree *stmt_p, int *walk_subtrees, void *data_) cp_walk_tree (&init, cp_fold_r, data, NULL); cp_walk_tree (&TARGET_EXPR_CLEANUP (stmt), cp_fold_r, data, NULL); *walk_subtrees = 0; - if (!flag_no_inline) + if (!flag_no_inline && !VOID_TYPE_P (TREE_TYPE (init))) { tree folded = maybe_constant_init (init, TARGET_EXPR_SLOT (stmt)); if (folded != init && TREE_CONSTANT (folded)) but maybe we also need an assert in cxx_eval_outermost_constant_expr checking that if there's an object, we don't fold away all the initializing bits?