This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Pathalogical divides
- To: geoffk at cygnus dot com, kenner at vlsi1 dot ultra dot nyu dot edu
- Subject: Re: Pathalogical divides
- From: dewar at gnat dot com (Robert Dewar)
- Date: Mon, 25 Sep 2000 02:07:04 -0400 (EDT)
- Cc: gcc at gcc dot gnu dot org
<<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 :-)