Program received signal SIGFPE, Arithmetic exception.
0x0000000000462cd5 in exp2 () at expr.c:761
761 val1 /= val2;
(gdb) print val1
$1 = -9223372036854775808
(gdb) print val2
$2 = -1

which is strange.

Not at all. Overflow invokes undefined behaviour.

But why there is no overflow on 32bit system?

No *detected* overflow.  For instance, if computing (2 ** 63)
gives 0 (the low-order 32 bits of the true result) and
does not detect the overflow (or ignores the overflow,
either by intention or by bug), then there is no problem
with computing (0 / -1).

--


Reply via email to