...
On systems where this assertion would fail, the following this compliant solution may be used to ensure signed overflow does not occur:
...
On Microsoft Visual Studio 2013, taking the modulo of LONG_MIN
by −1
results in abnormal termination on x86 and x64, . On GCC/Linux, taking the modulo of LONG_MIN
by −1
produces a floating-point exception. However, on GCC 4.2.4 and newer, with optimization enabled, taking the modulo of LONG_MIN
by −1
yields the value 0
.
...
Related Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
...