[GHC] #8695: Arithmetic overflow from (minBound :: Int) `quot` (-1)
GHC
ghc-devs at haskell.org
Tue Jan 28 23:28:36 UTC 2014
#8695: Arithmetic overflow from (minBound :: Int) `quot` (-1)
------------------------------------------------+--------------------------
Reporter: rleslie | Owner:
Type: bug | Status: patch
Priority: normal | Milestone: 7.8.1
Component: libraries/haskell2010 | Version: 7.6.3
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
Type of failure: Incorrect result at runtime | Unknown/Multiple
Test Case: | Difficulty:
Blocking: | Unknown
| Blocked By:
| Related Tickets: #1042
------------------------------------------------+--------------------------
Comment (by rwbarton):
Division is a totally different kind of operation than addition,
subtraction and multiplication! The reason that "performing arithmetic mod
2^n^" is sensible for the latter three is that they respect equality mod
2^n^ (Z/2^n^Z is a ring). Division does not. You can't take the Euclidean
domain approach to defining division mod 2^n^ anyways because there are
extra solutions, e.g. for `div 100 3` (mod 2^32^) we have 100 = 3 * 33 +
1, but also 100 = 3 * 1431655798 + 2 and 100 = 3 * 2863311564 + 0. The
only sensible notion of division mod 2^n^ is modular division by odd
numbers, but that's clearly not the role of `div` or `quot`.
So I don't give any weight to arguments-by-analogy such as "addition,
subtraction and multiplication can be computed by injecting into Integer,
performing the operation and reducing the result to an Int, hence so too
should division be".
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/8695#comment:23>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list