Mail Archives: djgpp/2003/04/22/10:00:09
Ben Peddell wrote:
> From your crash, it looks like the divide was being called something
> like:
> result = div(-3,-3);
Those args shouldn't even cause it to bomb. I think I had some problem
with -fomit-frame-pointer, but I'm still investigating.
> And the results:
>
> Linux div(40,-3) = -13, 1
> Asm div(40,-3) = -13, 1
> C div(40,-3) = -13, 1
> DJGPP div(40,-3) = -13, -1
According to C99:
6.5.5 Multiplicative operators
[#6] When integers are divided, the result of the / operator
is the algebraic quotient with any fractional part
discarded.78) If the quotient a/b is representable, the
expression (a/b)*b + a%b shall equal a.
...so the 2.03 DJGPP div() is incorrect, since (-13)*(-3) + (-1) != 40.
I knew this when I submitted 00314, but the log for 00314 claims that
the bug was fixed in 2000.
> I think you can see the odd one out.
>
> By the way, the libc reference in DJGPP says that the DJGPP result is
> correct.
OK, so we have a bug in the docs as well.
-Eric Rudd
rudd AT cyberoptics DOT com
- Raw text -