aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/libgnat/s-dourea.adb
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2022-04-04 23:16:53 +0200
committerPierre-Marie de Rodat <derodat@adacore.com>2022-05-18 08:41:03 +0000
commit7c77ec1199c3a3d1ac48c9d963b8389c10a2a5bf (patch)
tree904bee0edef98e3888ec13167fc9078842cac055 /gcc/ada/libgnat/s-dourea.adb
parentba89624e938a9309a0a8a672b2753159cf0a8a78 (diff)
downloadgcc-7c77ec1199c3a3d1ac48c9d963b8389c10a2a5bf.zip
gcc-7c77ec1199c3a3d1ac48c9d963b8389c10a2a5bf.tar.gz
gcc-7c77ec1199c3a3d1ac48c9d963b8389c10a2a5bf.tar.bz2
[Ada] Fix problematic underflow for Float_Type'Value
We need a couple of guards for boundary conditions in the support code. gcc/ada/ * libgnat/s-dourea.adb ("/"): Add guard for zero and infinite divisor. * libgnat/s-valuer.adb (Scan_Raw_Real): Add guard for very large exponent values.
Diffstat (limited to 'gcc/ada/libgnat/s-dourea.adb')
-rw-r--r--gcc/ada/libgnat/s-dourea.adb12
1 files changed, 12 insertions, 0 deletions
diff --git a/gcc/ada/libgnat/s-dourea.adb b/gcc/ada/libgnat/s-dourea.adb
index a6cf2a1..4f378d6 100644
--- a/gcc/ada/libgnat/s-dourea.adb
+++ b/gcc/ada/libgnat/s-dourea.adb
@@ -178,6 +178,12 @@ package body System.Double_Real is
P, R : Double_T;
begin
+ if Is_Infinity (B) or else Is_Zero (B) then
+ return (A.Hi / B, 0.0);
+ end if;
+ pragma Annotate (CodePeer, Intentional, "test always false",
+ "code deals with infinity");
+
Q1 := A.Hi / B;
-- Compute R = A - B * Q1
@@ -196,6 +202,12 @@ package body System.Double_Real is
R, S : Double_T;
begin
+ if Is_Infinity (B.Hi) or else Is_Zero (B.Hi) then
+ return (A.Hi / B.Hi, 0.0);
+ end if;
+ pragma Annotate (CodePeer, Intentional, "test always false",
+ "code deals with infinity");
+
Q1 := A.Hi / B.Hi;
R := A - B * Q1;