[clean-list] Program compiles and runs, with unpredictable result

John van Groningen johnvg at cs.ru.nl
Mon Oct 1 11:48:08 MEST 2007


David Norris wrote:
>The following experiment with modeling imperative 'for' loops in Clean produces programs exhibiting unpredictable behavior.  My impression is that it is necessary to set the SumLoop stop index large to obtain the behavior.  With that done, changing the end character of the CatLoop produces various results -- sometimes correct, sometimes not.
>
>Correct result:
>(5000050000,13,"abcdefg",{1,1,2,3,5,8,13},{4,13,22,15})
>
>Examples of incorrect results:
>(5000050000,13,"abcdefghijklmnopqrstuvwxyz",{1,1,2,3,5,8,13},{4,13,8.50705942721713e+37,15})
>(5000050000,13,"abcdefghijklmnopqrstuvw",{1,1,2,3,5,8,13},{4,13,-1.21290479585191e+229,15})
>(5000050000,13,"abc",{1,1,2,3,5,8,13},{4,13,22,9.52682081175185e+139})
>
>Does this represent a bug?

This may happen if "Check Indices" in the Project Option, tab Diagnostics
is disabled, and incorrect array indices are used.

Your program uses indices that are larger than the size of the array.
If you (re)enable the "Check Indices" option, you should get the following
runtime error when you run the program:

Run Time Error: index out of range

To locate the errors it may be usefull to enable Project Options / Profiling /
Stack trace only. Programs will run much slower with this option enabled, so
disable it again after you have found the bugs.

Kind regards,

John van Groningen


More information about the clean-list mailing list