#7233: Int64 division buggy on a 32-bit installation ------------------------------+--------------------------------------------- Reporter: lerkok | Owner: Type: bug | Status: new Priority: normal | Component: Compiler Version: 7.6.1 | Keywords: Os: Unknown/Multiple | Architecture: Unknown/Multiple Failure: None/Unknown | Testcase: Blockedby: | Blocking: Related: | ------------------------------+---------------------------------------------
Comment(by lerkok): Some more information. It appears that the expression: {{{ x `div` y }}} will be incorrectly computed for ```Int64``` values when the internal word size is 32 bits, in the following cases: {{{ 1. If x > 0 && y < 0, then whenever ((x-y)-1) overflows/underflows the Int64 range 2. if x < 0 && y > 0, then whenever ((x-y)+1) overflows/underflows the Int64 range }}} So, this will impact whenever the difference between ```x``` and ```y``` are rather large; but errors will pop-up regularly through the data-space, not just at end points. (That is, for every valid value of `x`, there's a value of `y` that will exhibit the bug; and vice versa.) I think the culprit is here: http://hackage.haskell.org/packages/archive/base/latest/doc/html/src/GHC- Int.html#divInt64. The code in there implements ```div``` in terms of ```quot```, computing``(x-y)-1``` and ```(x-y)+1``` without worrying about overflow/underflow. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/7233#comment:1> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs