From: jason Date: Thu, 24 Mar 2016 17:59:58 +0000 (+0000) Subject: PR c++/70323 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c3f376bfeeb30f5fce5ac94a30756a7447f62b7a;p=thirdparty%2Fgcc.git PR c++/70323 * constexpr.c (cxx_eval_call_expression): Don't cache result if *overflow_p. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@234463 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index dbef1b206f28..6512cc5b0a8a 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2016-03-24 Jason Merrill + + PR c++/70323 + * constexpr.c (cxx_eval_call_expression): Don't cache result if + *overflow_p. + 2016-03-24 Patrick Palka PR c++/62212 diff --git a/gcc/cp/constexpr.c b/gcc/cp/constexpr.c index 8427513854d4..2d30a8412793 100644 --- a/gcc/cp/constexpr.c +++ b/gcc/cp/constexpr.c @@ -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; diff --git a/gcc/testsuite/g++.dg/cpp0x/constexpr-70323a.C b/gcc/testsuite/g++.dg/cpp0x/constexpr-70323a.C new file mode 100644 index 000000000000..d166787ca8b3 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/constexpr-70323a.C @@ -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" }