comp.lang.ada
 help / color / mirror / Atom feed
From: wzm@clinux.org (wzm)
Subject: A Bug about GNAT 3.13p
Date: 19 Jan 2002 16:50:17 -0800
Date: 2002-01-20T00:50:18+00:00	[thread overview]
Message-ID: <5240f9fd.0201191650.2e71c7b1@posting.google.com> (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



             reply	other threads:[~2002-01-20  0:50 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-20  0:50 wzm [this message]
2002-01-20  1:35 ` A Bug about GNAT 3.13p tmoran
2002-01-20 11:57   ` wzm
2002-01-20 21:06 ` Robert Dewar
replies disabled

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