[GHC] #13023: strange behaviour of GHCi when int value exceed int range

#13023: strange behaviour of GHCi when int value exceed int range -------------------------------------+------------------------------------- Reporter: vanto | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: GHCi crash Unknown/Multiple | Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- import Data.Char type Bit = Int int2bin :: Int -> [Bit] int2bin 0 = [] int2bin n = reverse (n `mod`2 : (reverse (int2bin (n `div`2)))) When n = 4200000000, GHCi crash with "out of memory" but if n = 4300000000 GHCi send a result as [1,0,0,1,1,0,0,1,1,0,0,1,0,1,1,0,0,0,0,0,0,0,0] -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13023 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler

#13023: strange behaviour of GHCi when int value exceed int range -------------------------------------+------------------------------------- Reporter: vanto | Owner: Type: bug | Status: closed Priority: normal | Milestone: Component: GHCi | Version: 8.0.1 Resolution: invalid | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: GHCi crash | Test Case: Blocked By: | Blocking: Related Tickets: | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Changes (by rwbarton): * status: new => closed * resolution: => invalid Comment: I assume this is on a 32-bit system. Consider the fact that {{{(-1) `div` 2 = -1}}} and that repeatedly applying {{{`div` 2}}} to a negative `Int` (like `4200000000 = -94967296`) will eventually reach `-1`. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13023#comment:1 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC