From: Piotr Trojanek Date: Thu, 20 Feb 2025 18:25:02 +0000 (+0100) Subject: ada: Convert floating-point zero to machine representation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=032e2209fff5573ee018fb78ed4c238c5fac4226;p=thirdparty%2Fgcc.git 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 --git a/gcc/ada/sem_eval.adb b/gcc/ada/sem_eval.adb index 5d150636495..f5cd0449d61 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;