This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Ada] Fix some missing cases of floating-point validity checks


When a program is compiled with -gnatVaf, all floating-point results
of operators must be checked, since they might yield infinite or NaN
results. Some cases of required checks, notably the result of object
declarations with initialization expressions were not being checked.

The following program, compiled with -gnatVaf

     1. with Ada.Text_IO; use Ada.Text_IO;
     2.
     3. procedure Float_Div_Inf is
     4.    function Id (X : Float) return Float is (X);
     5.
     6.    A : Float := Id (1.0);
     7.    B : Float := Id (0.0);
     8.    C : Float := A / B;
     9. begin
    10.    Put_Line (C'Img);
    11.    C := B / B;
    12.    Put_Line (C'Img);
    13. end Float_Div_Inf;

must yield the output:

raised CONSTRAINT_ERROR : float_div_inf.adb:8 invalid data

Previously the check on line 8 was missing, line 10 printed out
+Inf, and then there was a validity check failure on line 11.

Tested on x86_64-pc-linux-gnu, committed on trunk

2014-01-24  Robert Dewar  <dewar@adacore.com>

	* checks.adb (Expr_Known_Valid): Result of fpt operator never
	considered valid.

Attachment: difs
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]