gm2
[Top][All Lists]
Advanced

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

Re: [Gm2] Bug in FOR Statement?


From: Gaius Mulley
Subject: Re: [Gm2] Bug in FOR Statement?
Date: 01 Dec 2005 08:08:55 +0000
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.4

Juan Reyes <address@hidden> writes:

> Hi to all,
> first of all, thanks for your job on developing this compiler.
> I have recently installed the compiler and works fine,
> but I found that when I compile and run this code:
> 
> MODULE fortest;
> 
> FROM InOut IMPORT WriteInt,WriteLn;
> 
>    VAR N,i: INTEGER;
> 
> BEGIN
>   N:=2;
>   FOR i:=N TO 1 BY -1 DO
>   WriteInt(i,2);
>   END;
>   WriteLn;
> END fortest.
> 
> 
> I get this output:
> 
>  2 1 0
> 
> So the FOR statement is evaluated 3 times instead of  2¿?
> 
> If in the FOR line you change N by 2 (or a constant), then the output is OK.
> 
> The version is 2005-11-15 with gcc 3-3-6.
> 
> J.R.

Hi,

many thanks again for the bug reports, I think the for loop
bugs have been fixed now, please can you verify?


Here is the latest changelog entry:

        * fixed bug reported by John Wallace and Juan Reyes
          concerning FOR loops with negative step values.
        * added new runtime regression tests gm2/pim/run/pass/For[78].mod
          to test these new changes.
        * changes to gm2/gm2-compiler/M2Base.mod, gm2-compiler/M2Code.mod,
          gm2/gm2-compiler/M2GenGCC.mod, gm2/gm2-compiler/M2Quads.mod
          to ensure that the Negate operator works on large data types
          LONGCARD contants are changed into LONGINT and overflow is
          checked.

However the fixes have raised another bug, namely checking for
constant overflows when folding expressions. For example the for loops
fixes break the arrayhuge.mod and arrayhuge2.mod regression test on 32
bit machines. I'll look into these shortly as well..

regards,
Gaius



reply via email to

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