aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2021-01-20 17:08:51 +0100
committerPierre-Marie de Rodat <derodat@adacore.com>2021-05-06 03:51:34 -0400
commitbcc6807c4bbcb782cc0f1453bb9275d52a7e1638 (patch)
treed679e6a2f3b746b986ce4db6b2a9bda10110d8bc /gcc
parente18e1b5f524507fd7b7d8bd4d674bc63333a5679 (diff)
downloadgcc-bcc6807c4bbcb782cc0f1453bb9275d52a7e1638.zip
gcc-bcc6807c4bbcb782cc0f1453bb9275d52a7e1638.tar.gz
gcc-bcc6807c4bbcb782cc0f1453bb9275d52a7e1638.tar.bz2
[Ada] Fix off-by-one bug in underflow handling of Scaling
gcc/ada/ * libgnat/s-fatgen.adb (Scaling): Fix off-by-one bug for underflow.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ada/libgnat/s-fatgen.adb9
1 files changed, 8 insertions, 1 deletions
diff --git a/gcc/ada/libgnat/s-fatgen.adb b/gcc/ada/libgnat/s-fatgen.adb
index 95c0549..145d4ac 100644
--- a/gcc/ada/libgnat/s-fatgen.adb
+++ b/gcc/ada/libgnat/s-fatgen.adb
@@ -784,7 +784,7 @@ package body System.Fat_Gen is
-- Check for gradual underflow
if T'Denorm
- and then Adjustment >= IEEE_Emin - (Mantissa - 1) - Exp
+ and then Adjustment >= IEEE_Emin - Mantissa - Exp
then
Expf := IEEE_Emin;
Expi := Exp + Adjustment - Expf;
@@ -807,6 +807,13 @@ package body System.Fat_Gen is
Float_Word (IEEE_Ebias + Expf) * Exp_Factor;
if Expi < 0 then
+ -- Given that Expi >= -Mantissa, only -64 is problematic
+
+ if Expi = -64 then
+ XX := XX / 2.0;
+ Expi := -63;
+ end if;
+
XX := XX / T (UST.Long_Long_Unsigned (2) ** (-Expi));
end if;