comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@cs.nyu.edu (Robert Dewar)
Subject: Re: GNAT and Ariane 5 crash
Date: 1996/08/02
Date: 1996-08-02T00:00:00+00:00	[thread overview]
Message-ID: <dewar.839020426@schonberg> (raw)
In-Reply-To: 32020E13.41C6@MSMAIL3.HAC.COM


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 :-)





      reply	other threads:[~1996-08-02  0:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-08-02  0:00 GNAT and Ariane 5 crash Pascal Ledru
1996-08-02  0:00 ` Robert Dewar [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox