[GHC] #5688: instance Read Integer/Rational/Double readsPrec out of memory and crash due to exponential notation

GHC cvs-ghc at haskell.org
Mon Dec 12 16:41:21 CET 2011


#5688: instance Read Integer/Rational/Double readsPrec out of memory and crash due
to exponential notation
---------------------------------+------------------------------------------
    Reporter:  gracjan           |       Owner:                  
        Type:  bug               |      Status:  patch           
    Priority:  highest           |   Milestone:  7.4.1           
   Component:  libraries/base    |     Version:  6.12.3          
    Keywords:                    |          Os:  Unknown/Multiple
Architecture:  Unknown/Multiple  |     Failure:  Runtime crash   
  Difficulty:  Unknown           |    Testcase:                  
   Blockedby:                    |    Blocking:                  
     Related:                    |  
---------------------------------+------------------------------------------

Comment(by gracjan):

 I've created separate ticket for report change and source code compile:

 http://hackage.haskell.org/trac/ghc/ticket/5692

 Also to document 6.12.3 behavior:

 {{{
 GHCi, version 6.12.3: http://www.haskell.org/ghc/
 Prelude> read "123e10" :: Integer
 1230000000000
 Prelude> read "123e10" :: Double
 1.23e12
 Prelude> read "123e10" :: Rational
 *** Exception: Prelude.read: no parse

 Prelude> 123e10 :: Integer

 <interactive>:1:0:
     No instance for (Fractional Integer)
       arising from the literal `1.23e12' at <interactive>:1:0-5
     Possible fix: add an instance declaration for (Fractional Integer)
     In the expression: 1.23e12 :: Integer
     In the definition of `it': it = 1.23e12 :: Integer
 Prelude> 123e10 :: Double
 1.23e12
 Prelude> 123e10 :: Rational
 1230000000000 % 1
 }}}

 So source code compile of Integer and Rational is not compatible with Read
 instances.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5688#comment:17>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler



More information about the Glasgow-haskell-bugs mailing list