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 validity check on some floating point operation


Tested on x86-linux

Validity checks were properly enabled on the operands of these operations,
but not on the result, which allowed the generation and propagation of abnormal
values (Infinities and NaN's).
Test p_test_float verifies that invalid values are properly
detected:

with TEXT_IO;
use TEXT_IO;

procedure P_TEST_FLOAT is
  V_1, V_2, V_3 : Long_Float; 
begin
  V_1 := 0.004389773266958945;
  V_2 := 0.0;

  V_3 := V_1 / V_2;
  put_line ("Failed: division by zero");
exception
  when constraint_error => put_line ("division by zero detected");
end P_TEST_FLOAT;

$ gnatmake -q -gnatVirofc p_test_float

2004-10-26  Ed Schonberg  <schonberg@gnat.com>

	* checks.adb (Expr_Known_Valid): If floating-point validity checks are
	enabled, check the result of unary and binary operations when the
	expression is the right-hand side of an assignment.

Attachment: difs.8
Description: Text document


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