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

GHC ghc-devs at haskell.org
Wed Dec 21 16:13:51 UTC 2016


#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


More information about the ghc-tickets mailing list