Commit 52228180 by Jason Merrill Committed by Jason Merrill

re PR c++/70323 (missing error on integer overflow in constexpr function result converted to bool)

	PR c++/70323

	* constexpr.c (cxx_eval_call_expression): Don't cache result if
	*overflow_p.

From-SVN: r234463
parent 8f085166
2016-03-24 Jason Merrill <jason@redhat.com>
PR c++/70323
* constexpr.c (cxx_eval_call_expression): Don't cache result if
*overflow_p.
2016-03-24 Patrick Palka <ppalka@gcc.gnu.org>
PR c++/62212
......
......@@ -1448,7 +1448,7 @@ cxx_eval_call_expression (const constexpr_ctx *ctx, tree t,
if (result == error_mark_node)
*non_constant_p = true;
if (*non_constant_p)
if (*non_constant_p || *overflow_p)
result = error_mark_node;
else if (!result)
result = void_node;
......
// PR c++/70323
// { dg-do compile { target c++11 } }
// { dg-options "-Wall" }
constexpr int overflow_if_0 (int i) { return __INT_MAX__ + !i; }
constexpr int overflow_if_1 (int i) { return __INT_MAX__ + i; }
constexpr bool i0_0 = overflow_if_0 (0); // { dg-error "overflow in constant expression" }
constexpr bool i0_1 = overflow_if_0 (1);
constexpr bool i1_0 = overflow_if_1 (0);
constexpr bool i1_1 = overflow_if_1 (1); // { dg-error "overflow in constant expression" }
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