[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: [PATCH] Loop Overflow Bug Fix
- From: Roberto Ierusalimschy <roberto@...>
- Date: Thu, 16 Nov 2017 09:01:51 -0200
> I have created an updated version of my Loop overflow patch, please find it
> attached to this post.
> In my previous patch I moved the pre-adjustment of the "step" value from the
> initial value to the limit value; this simply moved the edge case from one
> variable to the other, even if it did fix a number of normal loop use cases.
> This patch simply adjusts the logic of the loop instead of pre-adjusting the
> initial or limit values. Now, when the loop iterates an additional
> comparison is done after the limit check. If the difference between the
> limit and current value is greater or equal to the current step value do
> another loop iteration, if not abort the loop cycle.
> This now allows the following test script to succeed on all edge cases... if
> there are any other cases I have forgotten about, or if this patch has side
> effects I am unaware of please let me know. The patch fully passes the Lua
> Test Suite as well... although perhaps some of these edge cases should be
> added to the suite? :)
* What does you implementation do with limits outside the range of
integers, such as (for i = 1, 2^70 do ...)? (What should it do?)
* And for floating point arithmetic, like the following?
for i = 2^53 - 10, 2^53 + 10 do print(i) end
* Did you test the performance cost of the extra check?