* A Bug about GNAT 3.13p
@ 2002-01-20 0:50 wzm
2002-01-20 1:35 ` tmoran
2002-01-20 21:06 ` Robert Dewar
0 siblings, 2 replies; 4+ messages in thread
From: wzm @ 2002-01-20 0:50 UTC (permalink / raw)
when I was writing a small example for my ada tutorials,I found a
bug,the sorce code is:
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure comp is
function compare (A:Integer; B :Integer) return Integer is
begin
return (A - B);
end compare;
X,Y,Result:Integer;
begin
Put ("Enter A:"); Get (X);
Put ("Enter B:"); Get (Y);
Result := compare (X,Y);
Put(Result);
Put(Integer'Last);
case Result is
when Integer'First..-1 => Put_Line (" A < B.");
when 0 => Put_Line (" A = B.");
when 1..Integer'Last => Put_Line (" A > B.");
when others => null;
end case;
end comp;
the program can compile successfully,but when run:
Enter A:1234567890
Enter B:-1234567890
A < B
of course,it's wrong,and the value of Result became
-1825831516.
In this case,raising Constraint_error shoud be suitable
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A Bug about GNAT 3.13p
2002-01-20 0:50 A Bug about GNAT 3.13p wzm
@ 2002-01-20 1:35 ` tmoran
2002-01-20 11:57 ` wzm
2002-01-20 21:06 ` Robert Dewar
1 sibling, 1 reply; 4+ messages in thread
From: tmoran @ 2002-01-20 1:35 UTC (permalink / raw)
> Enter A:1234567890
> Enter B:-1234567890
> A < B
It's not a bug, it's a feature. If you want the Gnat compiler to
implement Ada, you'll need the "-gnato" option. Without that option, it
implements a slightly different language in which integer overflow is not
checked. It's documented. It also serves nicely to separate the
cognoscenti from the masses.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A Bug about GNAT 3.13p
2002-01-20 1:35 ` tmoran
@ 2002-01-20 11:57 ` wzm
0 siblings, 0 replies; 4+ messages in thread
From: wzm @ 2002-01-20 11:57 UTC (permalink / raw)
tmoran@acm.org wrote in message news:<99p28.35119$_t6.1630727346@newssvr14.news.prodigy.com>...
> > Enter A:1234567890
> > Enter B:-1234567890
> > A < B
> It's not a bug, it's a feature. If you want the Gnat compiler to
> implement Ada, you'll need the "-gnato" option. Without that option, it
> implements a slightly different language in which integer overflow is not
> checked. It's documented. It also serves nicely to separate the
> cognoscenti from the masses.
Thank you!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: A Bug about GNAT 3.13p
2002-01-20 0:50 A Bug about GNAT 3.13p wzm
2002-01-20 1:35 ` tmoran
@ 2002-01-20 21:06 ` Robert Dewar
1 sibling, 0 replies; 4+ messages in thread
From: Robert Dewar @ 2002-01-20 21:06 UTC (permalink / raw)
wzm@clinux.org (wzm) wrote in message news:<5240f9fd.0201191650.2e71c7b1@posting.google.com>...
> when I was writing a small example for my ada tutorials,I
> found a bug,the sorce code is:
This is not a bug, it is a test on whether you have read
the documentation. You failed the test :-)
Hint: look up -gnato, and while you are at it, check into
all the other compiler options since there are lots of nice
features there.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2002-01-20 21:06 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-01-20 0:50 A Bug about GNAT 3.13p wzm
2002-01-20 1:35 ` tmoran
2002-01-20 11:57 ` wzm
2002-01-20 21:06 ` Robert Dewar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox