* [Ada] Fix minor issue in Scan_Decimal_Digits
@ 2021-04-29 8:03 Pierre-Marie de Rodat
0 siblings, 0 replies; only message in thread
From: Pierre-Marie de Rodat @ 2021-04-29 8:03 UTC (permalink / raw)
To: gcc-patches; +Cc: Eric Botcazou
[-- Attachment #1: Type: text/plain, Size: 337 bytes --]
The Extra digit is not correctly set when the precision limit is reached
by means of trailing zeros.
Tested on x86_64-pc-linux-gnu, committed on trunk
gcc/ada/
* libgnat/s-valuer.adb (Scan_Decimal_Digits): Set Extra to zero
when the precision limit is reached by means of trailing zeros
and prevent it from being overwritten later.
[-- Attachment #2: patch.diff --]
[-- Type: text/x-diff, Size: 1321 bytes --]
diff --git a/gcc/ada/libgnat/s-valuer.adb b/gcc/ada/libgnat/s-valuer.adb
--- a/gcc/ada/libgnat/s-valuer.adb
+++ b/gcc/ada/libgnat/s-valuer.adb
@@ -261,7 +261,11 @@ package body System.Value_R is
Scale := Scale - 1;
else
+ Extra := 0;
Precision_Limit_Reached := True;
+ if Round and then J = Trailing_Zeros then
+ Round_Extra (Digit, Value, Scale, Extra, Base);
+ end if;
exit;
end if;
end loop;
@@ -274,11 +278,16 @@ package body System.Value_R is
Temp := Value * Uns (Base) + Uns (Digit);
+ -- Precision_Limit_Reached may have been set above
+
+ if Precision_Limit_Reached then
+ null;
+
-- Check if Temp is larger than Precision_Limit, taking into
-- account that Temp may wrap around when Precision_Limit is
-- equal to the largest integer.
- if Value <= Umax
+ elsif Value <= Umax
or else (Value <= UmaxB
and then ((Precision_Limit < Uns'Last
and then Temp <= Precision_Limit)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-29 8:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-29 8:03 [Ada] Fix minor issue in Scan_Decimal_Digits Pierre-Marie de Rodat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).