GNAT and Ariane 5 crash 
Author Message
 GNAT and Ariane 5 crash

The following code:

with Text_IO;
use Text_IO;
procedure test is
  F : Float;
  I : Integer;
begin
  F := 1.0e31;
  I := Integer( F );
  Put_Line( Integer'Image(I) );
end;

displays 2147483647 with GNAT (3.04 on SGI)
while it displays (correctly I think) numeric_error
with another compiler.



Tue, 19 Jan 1999 03:00:00 GMT  
 GNAT and Ariane 5 crash

Pascal said

"with Text_IO;
use Text_IO;
procedure test is
  F : Float;
  I : Integer;
begin
  F := 1.0e31;
  I := Integer( F );
  Put_Line( Integer'Image(I) );
end;"

should display Numeric_Error.

That is incorrect, there is no such exception in Ada 95, the exception
raised by the above program is Constraint_Error. Ada 83 compilers should
also raise Constraint_Error rather than Numeric_Error, but some old Ada 83
compilers were never fixed to give the recommended behavior (Numeric_Error
is not wrong in Ada 83, just not recommended, but would be wrong in Ada 95).

Assuming you enable overflow checking (using the -gnato switch as documented
in the GNAT documentation -- worth reading!) then you get the expected
result Constraint_Error from GNAT. Probably your incorrect result was a r
result of not reading the documentation and hence not knowing you should
set the -gnato switch.

P.S. Before anyone starts a thread on this switch in GNAT, please consult
the comp.lang.ada archives for long discussion threads on this switch and
don't post unless you have something new to say :-)



Tue, 19 Jan 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Ariane Crash (Was: Adriane crash)

2. Papers on the Ariane-5 crash and Design by Contract

3. Papers on the Ariane-5 crash and Design by Contract

4. Software Bug crashes European Rocket, Ariane 5.

5. GNAT compiles its e.g.'s, but they crash

6. Multiple reasons for failure of Ariane 5 (was: Re: Ariane 5 - not an exception?)

7. Ariane 5 - not an exception?

8. Ariane-5 Disaster

9. Ariane 5 Failure - Summary Report

10. Ariane 5 failure

11. Ariane 5 failure

12. Ariane 5 failure

 

 
Powered by phpBB® Forum Software