* Re: GNAT and Ariane 5 crash
1996-08-02 0:00 GNAT and Ariane 5 crash Pascal Ledru
@ 1996-08-02 0:00 ` Robert Dewar
0 siblings, 0 replies; 2+ messages in thread
From: Robert Dewar @ 1996-08-02 0:00 UTC (permalink / raw)
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 :-)
^ permalink raw reply [flat|nested] 2+ messages in thread
* GNAT and Ariane 5 crash
@ 1996-08-02 0:00 Pascal Ledru
1996-08-02 0:00 ` Robert Dewar
0 siblings, 1 reply; 2+ messages in thread
From: Pascal Ledru @ 1996-08-02 0:00 UTC (permalink / raw)
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.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~1996-08-02 0:00 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-08-02 0:00 GNAT and Ariane 5 crash Pascal Ledru
1996-08-02 0:00 ` Robert Dewar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox