From: Eric Botcazou Date: Wed, 20 Jan 2021 16:08:51 +0000 (+0100) Subject: [Ada] Fix off-by-one bug in underflow handling of Scaling X-Git-Tag: basepoints/gcc-13~7768 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bcc6807c4bbcb782cc0f1453bb9275d52a7e1638;p=thirdparty%2Fgcc.git [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. --- diff --git a/gcc/ada/libgnat/s-fatgen.adb b/gcc/ada/libgnat/s-fatgen.adb index 95c0549e53c6..145d4ac9b0ec 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;