diff mbox series

[Ada] Fix incomplete narrowing FP conversion for Machine_Overflows

Message ID 3080506.aIK83GraIe@polaris
State New
Headers show
Series [Ada] Fix incomplete narrowing FP conversion for Machine_Overflows | expand

Commit Message

Eric Botcazou March 6, 2018, 12:21 p.m. UTC
On platforms where System'Machine_Overflows is true, the compiler generates a 
check only for the lower bound of the output type in a narrowing floating-
point conversion, which means that e.g. the last chance handler will not be 
invoked if the value overflows the upper bound of the output type.

Applied on all active branches.


2018-03-06  Eric Botcazou  <ebotcazou@adacore.com>

	* gcc-interface/trans.c (convert_with_check): Fix typo in the condition
	guarding the overflow check emitted for the upper bound of a floating-
	point conversion.
diff mbox series

Patch

Index: gcc-interface/trans.c
===================================================================
--- gcc-interface/trans.c	(revision 258231)
+++ gcc-interface/trans.c	(working copy)
@@ -9381,7 +9381,7 @@  convert_with_check (Entity_Id gnat_type,
 	  ? tree_int_cst_lt (gnu_out_ub, gnu_in_ub)
 	  : (FLOAT_TYPE_P (gnu_base_type)
 	     ? real_less (&TREE_REAL_CST (gnu_out_ub),
-			  &TREE_REAL_CST (gnu_in_lb))
+			  &TREE_REAL_CST (gnu_in_ub))
 	     : 1))
 	gnu_cond
 	  = build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node, gnu_cond,