]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Ada] Raise Constraint_Error for Compose and Scaling if Machine_Overflows
authorEric Botcazou <ebotcazou@adacore.com>
Mon, 25 Jan 2021 18:22:39 +0000 (19:22 +0100)
committerPierre-Marie de Rodat <derodat@adacore.com>
Fri, 7 May 2021 09:28:55 +0000 (05:28 -0400)
gcc/ada/

* libgnat/s-fatgen.adb (Scaling): Raise Constraint_Error in the
overflow case when T'Machine_Overflows is True.

gcc/ada/libgnat/s-fatgen.adb

index ec376e73e45d9426a8707a81f15fe15d50d99c42..e591ccad6c4bd4f9f95a75b842acb33346aad1c0 100644 (file)
@@ -771,12 +771,19 @@ package body System.Fat_Gen is
          --  Check for overflow
 
          if Adjustment > IEEE_Emax - Exp then
-            XX := 0.0;
-            return (if Minus then -1.0 / XX else 1.0 / XX);
-            pragma Annotate
-              (CodePeer, Intentional, "overflow check", "Infinity produced");
-            pragma Annotate
-              (CodePeer, Intentional, "divide by zero", "Infinity produced");
+            --  Optionally raise Constraint_Error as per RM A.5.3(29)
+
+            if T'Machine_Overflows then
+               raise Constraint_Error with "Too large exponent";
+
+            else
+               XX := 0.0;
+               return (if Minus then -1.0 / XX else 1.0 / XX);
+               pragma Annotate (CodePeer, Intentional, "overflow check",
+                                "Infinity produced");
+               pragma Annotate (CodePeer, Intentional, "divide by zero",
+                                "Infinity produced");
+            end if;
 
          --  Check for underflow