@@ -6991,6 +6991,11 @@ cxx_eval_constant_expression (const constexpr_call *call, tree t,
conversion. */
return fold (t);
r = fold_build1 (TREE_CODE (t), to, op);
+ /* Conversion of an out-of-range value has implementation-defined
+ behavior; the language considers it different from arithmetic
+ overflow, which is undefined. */
+ if (TREE_OVERFLOW_P (r) && !TREE_OVERFLOW_P (op))
+ TREE_OVERFLOW (r) = false;
}
break;
@@ -44,5 +44,4 @@ extern template struct A3<int, 510>;
// Use.
A3<int, 1111> a31;
-// FIXME should this be an error?
A3<char, 9999> a32; // { dg-warning "overflow" }
new file mode 100644
@@ -0,0 +1,8 @@
+// PR c++/47504
+// { dg-options -std=c++0x }
+
+char constexpr sub(char arg)
+{ return char(arg - char(1)); }
+
+int main()
+{ static char constexpr m = sub(-1); }