Pathalogical divides

Robert Dewar dewar@gnat.com
Mon Sep 25 02:35:00 GMT 2000


<<Yes.  C interpreters are permitted to do anything they like when
signed integer arithmetic overflows, including producing a signal.
>>

Actually while I think that is a valid interpretation of K&R rules,
it is VERY difficult to read the ANSI standard this way, check out
the exact wording, which seems to imply that the result is implementation
defined within certain limits, but I cannot read it to allow a signal.

By the way, the most efficient way of computing a%b to avoid
this problem is a%(abs b) being careful NOT to check for overflow
on the abs operation (not that one is likely to do so in C anyway :-)



More information about the Gcc mailing list