lua-users home
lua-l archive

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


On 21 June 2016 at 14:06, Sergey Zakharchenko <doublef.mobile@gmail.com> wrote:
> Off the top of my head, there's something in your environment (gcc and
> clang runtime?) that's configuring the FPU to raise exceptions instead
> of return NaNs (via fesetexceptflag()?). Check with fegetexceptflag().

As my post says, I see this output because I turned on the various
sanitizers when compiling (which are designed to help you find where
your code invokes undefined behaviour).

In C, dividing a double by zero is undefined. From C89 draft standard
http://port70.net/~nsz/c/c89/c89-draft.html#3.3.5:
> The result of the / operator is the quotient from the division of the first operand by the second; the result of the % operator is the remainder. In both operations, if the value of the second operand is zero, the behavior is undefined.

C99 has much the same to say: http://port70.net/~nsz/c/c99/n1256.html#6.5.5p5