gm2
[Top][All Lists]
Advanced

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

Re: [Gm2] more FOR loop bugs


From: Gaius Mulley
Subject: Re: [Gm2] more FOR loop bugs
Date: 21 Nov 2005 13:56:30 +0000
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

John B Wallace Jr <address@hidden> writes:

> 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

Hi John,

many thanks for the error reports and test code,

regards,
Gaius



reply via email to

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