...
On x86 platforms, the modulo operator for signed integers is implemented by the idiv
instruction code, along with the divide operator. Because INTLONG_MIN / -1
overflows, this code will throw a floating-point exception on INTLONG_MIN % -1
.
On Microsoft Visual Studio 20122013, taking the modulo of INTLONG_MIN
by −1
yields the value 0
results in abnormal termination on x86 and x64, . On GCC/Linux, taking the modulo of INTLONG_MIN
by −1
produces a floating-point exception. However, on GCC 4.2.4 and newer, with optimization enabled, taking the modulo of INTLONG_MIN
by −1
yields the value 0
.
...
...