...
Wiki Markup |
---|
Consider subtraction. If the user types the expression {{a - b}} where both a and b are in the range {{\[INT_MIN/2, INT_MAX/2\]}}, then the result will be in the range {{(INT_MIN, INT_MAX]}} for a typical two's complement machine. |
Wiki Markup |
---|
Now, if the user types {{a < b}}, there is often an implicit subtraction happening. On a machine without condition codes, the compiler may simply issue a subtract instruction and check whether the result is negative. This is allowed, because the compiler is allowed to assume there is no overflow. If all explicitly user-generated values are kept in the range {{\[INT_MIN/2, INT_MAX/2\]}}, then comparisons will always work even if the compiler performs this optimization on such hardware. |
Noncompliant Code Example
...