Paolo Carlini wrote:
Andrew Haley wrote:

Paolo Carlini writes:
> > I would like to understand the issue better, however...

What more is there to understand?  It's an integer overflow.  The
processor generates a trap on integer overflows during division
operations.
Yes, sorry, now I see that in the specific case it's just an overflow, like INT_MAX + 1. I was more interested in % in general for negative operands: for actual CPUs what do we know beyond the standard?

No, Paolo: the result of INT_MIN % -1 is zero, according to the standard.
There is no overflow whatsoever involved.  The overflow that you see is
simply an artifact of GCC that produces assembly code that does not implement
remainder expressions correctly.

--
Prof. Roberto Bagnara
Computer Science Group
Department of Mathematics, University of Parma, Italy
http://www.cs.unipr.it/~bagnara/
mailto:[EMAIL PROTECTED]

Reply via email to