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  <ebotca...@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.

Eric Botcazou
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))
 	  = build_binary_op (TRUTH_ORIF_EXPR, boolean_type_node, gnu_cond,

Reply via email to