[Gambas-devel] gb3: recent revision regarding FOR...NEXT loops and counter variables
Benoît Minisini
gambas at ...1...
Thu Sep 1 13:35:04 CEST 2011
> Holy shit something is seriously wrong with a recent commit. All my
> loops are going infinitely by wrapping around to negative values. Guess
> no one's using the most recent build or they'd have noticed. Try
> something like this in a module with no other code:
>
> ' Gambas module file
>
> Public Sub Main()
>
> Dim Counter As Short
>
> For Counter = 0 To 32767
> Print Counter
> Next
>
> End
There was a bug fix in loop management.
And your loop must loop indefinitely, because a short value wraps to -32768
after 32767, so the limit is never passed.
The solution is not using a Short as loop variable.
Regards,
--
Benoît Minisini
More information about the Devel
mailing list