2017-02-16 Jason Merrill <jason@redhat.com>
+ PR c++/78572 - ICE with self-modifying array initializer
+ * constexpr.c (cxx_eval_store_expression): The object we're
+ initializing is outside the constant-expression.
+ (cxx_eval_call_expression): Set ctx->call.
+
PR c++/79050 - ICE with undeduced auto and LTO
* decl.c (poplevel): Remove undeduced auto decls.
constexpr_ctx ctx_with_save_exprs = *ctx;
hash_set<tree> save_exprs;
ctx_with_save_exprs.save_exprs = &save_exprs;
+ ctx_with_save_exprs.call = &new_call;
tree jump_target = NULL_TREE;
cxx_eval_constant_expression (&ctx_with_save_exprs, body,
/* And then find/build up our initializer for the path to the subobject
we're initializing. */
tree *valp;
- if (DECL_P (object))
+ if (object == ctx->object && VAR_P (object)
+ && DECL_NAME (object) && ctx->call == NULL)
+ /* The variable we're building up an aggregate initializer for is outside
+ the constant-expression, so don't evaluate the store. We check
+ DECL_NAME to handle TARGET_EXPR temporaries, which are fair game. */
+ valp = NULL;
+ else if (DECL_P (object))
valp = ctx->values->get (object);
else
valp = NULL;