https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30484

--- Comment #13 from joseph at codesourcery dot com <joseph at codesourcery dot 
com> ---
For -fwrapv, the mathematical values of INT_MIN / -1 and INT_MIN % -1 
should be reduced using modulo arithmetic, so both operations are 
well-defined, and there is a bug then either operation causes SIGFPE or 
fails to produce the correct modulo result.

Without -fwrapv, INT_MIN / -1 is not representable, so "otherwise, the 
behavior of both a/b and a%b is undefined" (C11 and later, considered as a 
defect fix for older standard revisions) applies to make both operations 
undefined, and there is no bug.

That is, there is a bug in the -fwrapv case (when the operations should 
give well-defined results but GCC fails to implement that), but not in the 
-fno-wrapv case because both operations are undefined if either one is.

Reply via email to