comp.lang.ada
 help / color / mirror / Atom feed
* 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&#65292;but when run:

Enter A:1234567890
Enter B:-1234567890
A < B

of course&#65292;it's wrong&#65292;and the value of Result became
-1825831516.
In this case&#65292;raising Constraint_error shoud be suitable



^ 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