Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

On gcc/Linux, taking the modulo of INT_MIN by -1 produces a floating-point exception. However, on gcc 4.2.4, with optimization enabled, taking the modulo of INT_MIN by -1 yields the value 0.

Compliant Solution

This compliant solution tests the modulo operand to guarantee there is no possibility of a divide-by-zero error or an overflow error.

...