gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gm2] more FOR loop bugs


From: John B Wallace Jr
Subject: [Gm2] more FOR loop bugs
Date: Sat, 19 Nov 2005 16:09:35 -0500
User-agent: KMail/1.8

Here are two test modules that show some additional FOR loop bugs when
negative values are used:


MODULE FORLoopBug;

(*******************************************************************)
(*        NOTE: THIS IS TEST CODE AND MAY BE INCORRECT             *)
(*******************************************************************)

FROM InOut IMPORT WriteInt, WriteLn;

PROCEDURE DownLoop;
  VAR
    i, j : INTEGER;
  BEGIN
    j := 4;
    FOR i := j TO 0 BY -1 DO
      WriteInt(i,0);
      WriteLn
    END; (* FOR *)
  END DownLoop;

BEGIN
  DownLoop
END FORLoopBug.

On my system the output is:

4
3
2
1
0
-1
-2
-3
-4
-5
-6
-7
-8
-9
..
..
..

The loop does not halt at the final value.



MODULE LongFORBug;

(*******************************************************************)
(*        NOTE: THIS IS TEST CODE AND MAY BE INCORRECT             *)
(*******************************************************************)

FROM InOut IMPORT WriteString, WriteLn;

FROM LongIO IMPORT WriteLongInt;

VAR
  J : LONGINT;

BEGIN
  FOR J := -256000000000 TO 256000000000 BY 800000 DO
    WriteLongInt(J,20);
    WriteLn
  END; (* FOR *)
  WriteString('end');
  WriteLn
END LongFORBug.

On my system the output is:

end

The loop doesn't execute at all. If the initial value for J is
positive, the loop executes correctly.



The gm2 version is 15 November 2005 (plus gcc-3.3.6).

As before, my system is SUSE Linux 9.3-64 / Athlon 64.


John Wallace



reply via email to

[Prev in Thread] Current Thread [Next in Thread]