lua-users home
lua-l archive

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

> [...] What about this check?
>     n = e - f;
>     luaL_argcheck(L, t+n >= t, 4, "destination index overflows");
>     for (i = 0; i <= n; i++)

A good compiler can throw away the test 't+n>=t': It knows that 'n'
is non negative, because of a previous 'if e >= f', and it can assume
that signed arithmetic operations do not overflow (as overflows have
undefined behavior in the standard).

(Your code also has a problem when 'n' is maxinteger, because then the
for loop will never end.)

-- Roberto