re PR c++/51433 (constexpr caching leads to incorrect dynamic initialization)

PR c++/51433
	* semantics.c (cxx_eval_call_expression): Always retry previously
	non-constant expressions.

From-SVN: r183065
This commit is contained in:
Jason Merrill 2012-01-10 09:37:26 -05:00 committed by Jason Merrill
parent 91f074ced1
commit a1e0490fb8
4 changed files with 21 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2012-01-10 Jason Merrill <jason@redhat.com>
PR c++/51433
* semantics.c (cxx_eval_call_expression): Always retry previously
non-constant expressions.
2012-01-06 Jason Merrill <jason@redhat.com>
DR 686

View File

@ -6576,7 +6576,7 @@ cxx_eval_call_expression (const constexpr_call *old_call, tree t,
else
{
result = entry->result;
if (!result || (result == error_mark_node && !allow_non_constant))
if (!result || result == error_mark_node)
result = (cxx_eval_constant_expression
(&new_call, new_call.fundef->body,
allow_non_constant, addr,

View File

@ -1,3 +1,8 @@
2012-01-10 Jason Merrill <jason@redhat.com>
PR c++/51433
* g++.dg/cpp0x/constexpr-cache1.C: New.
2012-01-10 Richard Guenther <rguenther@suse.de>
PR tree-optimization/51801

View File

@ -0,0 +1,9 @@
// PR c++/51433
// { dg-options -std=c++0x }
constexpr int f();
constexpr int g() { return f(); }
extern const int n = g(); // dynamic initialization
constexpr int f() { return 42; }
extern const int m = g();
static_assert(m == 42, "m == 42");