Commit c598e5fa by Jason Merrill Committed by Jason Merrill

re PR c++/47504 ([C++0x] some constexpr calculations erroneously overflow when…

re PR c++/47504 ([C++0x] some constexpr calculations erroneously overflow when using negative numbers)

	PR c++/47504
	* semantics.c (cxx_eval_constant_expression) [NOP_EXPR]: Don't let
	the conversion set TREE_OVERFLOW.

From-SVN: r171116
parent 8b29c87a
2011-03-17 Jason Merrill <jason@redhat.com>
PR c++/47504
* semantics.c (cxx_eval_constant_expression) [NOP_EXPR]: Don't let
the conversion set TREE_OVERFLOW.
Core 1212
* semantics.c (finish_decltype_type): Return T&& for xvalue.
* typeck.c (unlowered_expr_type): Preserve cv-quals.
......
......@@ -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;
......
2011-03-17 Jason Merrill <jason@redhat.com>
* g++.dg/cpp0x/constexpr-overflow2.C: New.
* g++.dg/cpp0x/constexpr-data2.C: Remove FIXME.
2011-03-17 Eric Botcazou <ebotcazou@adacore.com>
* gnat.dg/specs/elab2.ads: New test.
......
......@@ -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" }
// 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); }
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