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
This commit is contained in:
parent
8f085166f8
commit
52228180f1
|
@ -1,3 +1,9 @@
|
|||
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;
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
// 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" }
|
Loading…
Reference in New Issue