Commit 96a4ef9d by Jason Merrill Committed by Jason Merrill

re PR c++/70344 (ICE on invalid code at -O1 and above on x86_64-linux-gnu in…

re PR c++/70344 (ICE on invalid code at -O1 and above on x86_64-linux-gnu in record_reference, at cgraphbuild.c:64)

	PR c++/70344

	* constexpr.c (cxx_eval_call_expression): Catch invalid recursion.

From-SVN: r234434
parent fbdb6baf
2016-03-23 Jason Merrill <jason@redhat.com>
PR c++/70344
* constexpr.c (cxx_eval_call_expression): Catch invalid recursion.
2016-03-23 Marek Polacek <polacek@redhat.com>
PR c++/69884
......
......@@ -1239,6 +1239,21 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
return t;
}
if (fun == current_function_decl)
{
/* A call to the current function, i.e.
constexpr int f (int i) {
constexpr int j = f(i-1);
return j;
}
This would be OK without the constexpr on the declaration of j. */
if (!ctx->quiet)
error_at (loc, "%qD called in a constant expression before its "
"definition is complete", fun);
*non_constant_p = true;
return t;
}
constexpr_ctx new_ctx = *ctx;
if (DECL_CONSTRUCTOR_P (fun) && !ctx->object
&& TREE_CODE (t) == AGGR_INIT_EXPR)
......
// PR c++/70344
// { dg-do compile { target c++11 } }
struct Z
{
Z () = default;
Z (Z const &) = default;
constexpr Z (Z &&) {}
};
constexpr int
fn (Z v)
{
return fn (v);
}
auto t = fn (Z ());
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment