From: Eric Botcazou <ebotca...@adacore.com>

The test as currently written is incorrect for odd bases.

gcc/ada/ChangeLog:

        * libgnat/s-valuer.adb (Round_Extra): Use multiplicative test.

Tested on x86_64-pc-linux-gnu, committed on master.

---
 gcc/ada/libgnat/s-valuer.adb | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/gcc/ada/libgnat/s-valuer.adb b/gcc/ada/libgnat/s-valuer.adb
index 6f557e93207..93e292cc34f 100644
--- a/gcc/ada/libgnat/s-valuer.adb
+++ b/gcc/ada/libgnat/s-valuer.adb
@@ -135,7 +135,9 @@ package body System.Value_R is
       B : constant Uns := Uns (Base);
 
    begin
-      if Digit >= Base / 2 then
+      --  Beware that Base may be odd
+
+      if 2 * Unsigned (Digit) >= Base then
 
          --  If Extra is maximum, round Value
 
-- 
2.43.0

Reply via email to