PR c++/70323
* constexpr.c (cxx_eval_constant_expression): Diagnose overflow
on TREE_OVERFLOW constants.
* g++.dg/cpp0x/constexpr-70323.C: New test.
From-SVN: r234438
2016-03-23 Jakub Jelinek <jakub@redhat.com>
+ PR c++/70323
+ * constexpr.c (cxx_eval_constant_expression): Diagnose overflow
+ on TREE_OVERFLOW constants.
+
PR c++/70376
* cp-gimplify.c (genericize_omp_for_stmt): Don't walk OMP_FOR_CLAUSES
for OMP_TASKLOOP here.
}
if (CONSTANT_CLASS_P (t))
{
- if (TREE_OVERFLOW (t) && (!flag_permissive || ctx->quiet))
- *overflow_p = true;
+ if (TREE_OVERFLOW (t))
+ {
+ if (!ctx->quiet)
+ permerror (input_location, "overflow in constant expression");
+ if (!flag_permissive || ctx->quiet)
+ *overflow_p = true;
+ }
return t;
}
+2016-03-23 Jakub Jelinek <jakub@redhat.com>
+
+ PR c++/70323
+ * g++.dg/cpp0x/constexpr-70323.C: New test.
+
2016-03-23 Alexandre Oliva <aoliva@redhat.com>
Jason Merrill <jason@redhat.com>
Jakub Jelinek <jakub@redhat.com>
--- /dev/null
+// PR c++/70323
+// { dg-do compile { target c++11 } }
+
+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" }