]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Convert floating-point zero to machine representation
authorPiotr Trojanek <trojanek@adacore.com>
Thu, 20 Feb 2025 18:25:02 +0000 (19:25 +0100)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Fri, 6 Jun 2025 08:37:07 +0000 (10:37 +0200)
When statically evaluating floating-point expressions we convert the final
result to machine number. However, we skipped this conversion if the result was
zero.

This inconsistency was introduced when adding a warning for compile-time
evaluation that gives different result from a run-time evaluation, but left
when this warning was deconstructed. It causes a crash in GNATprove, which
expects all floating-point numbers in the GNAT AST to be in a machine
representation form.

gcc/ada/ChangeLog:

* sem_eval.adb (Check_Non_Static_Context): Remove special handling of
floating-point zero.

gcc/ada/sem_eval.adb

index 5d1506364956ca4bb5d8d501e808f7d247e292c5..f5cd0449d61733ca51ae42c5f0a1c60a169fb9fe 100644 (file)
@@ -574,13 +574,11 @@ package body Sem_Eval is
 
          Rewrite (N, New_Copy (N));
 
-         if not Is_Floating_Point_Type (T) then
-            Set_Realval
-              (N, Corresponding_Integer_Value (N) * Small_Value (T));
-
-         elsif not UR_Is_Zero (Realval (N)) then
+         if Is_Floating_Point_Type (T) then
             Set_Realval (N, Machine_Number (Base_Type (T), Realval (N), N));
             Set_Is_Machine_Number (N);
+         else
+            Set_Realval (N, Corresponding_Integer_Value (N) * Small_Value (T));
          end if;
 
       end if;