Re: Weird numeric for loop counter variable behavior

  • From: Daniel Kolesa <quaker66@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 6 Mar 2014 12:18:42 +0000

Nah, his snippet should never print anything. Unless there is something
else wrong with his code elsewhere I suspect a bug


2014-03-06 12:15 GMT+00:00 <bobk@xxxxxxxxxxxxx>:

> Cheyi:
> This is normal behavior in almost all programming languages with For
> constructs. The counter variable "i" is incremented until the test for it
> being greater than the terminating value "N" is true and the loop is then
> exited.
>
> Bob Krummenacker
>
>
> On March 6, 2014 1:54:38 AM EST, Cheyi Lin <cheyi.lin@xxxxxxxxx> wrote:
>>
>> Hi, I have a rare numeric for loop variable behavior in LuaJIT 2.0.2:
>>
>> local N = 4
>> for i = 1, N do
>>   if i < 0 or i > 4 then
>>     print(i, N)  -- Is this possible ??
>>   end
>> end
>>
>> Yes, It really happened a couple of times a week in my project, I got
>> i = 5 and N = 4 !
>>
>> How did it happen? Could someone give me some clues/hints?
>> Thanks.
>>
>> Cheyi
>>
>>

Other related posts: