https://gcc.gnu.org/g:032e2209fff5573ee018fb78ed4c238c5fac4226

commit r16-1222-g032e2209fff5573ee018fb78ed4c238c5fac4226
Author: Piotr Trojanek <troja...@adacore.com>
Date:   Thu Feb 20 19:25:02 2025 +0100

    ada: Convert floating-point zero to machine representation
    
    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.

Diff:
---
 gcc/ada/sem_eval.adb | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb
index 5d1506364956..f5cd0449d617 100644
--- a/gcc/ada/sem_eval.adb
+++ b/gcc/ada/sem_eval.adb
@@ -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;

Reply via email to