#5688: instance Read Integer/Rational/Double readsPrec out of memory and crash 
due
to exponential notation
---------------------------------+------------------------------------------
    Reporter:  gracjan           |       Owner:  igloo           
        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 igloo):

 I assume the patch we want is 0001-Added-new-Exp-constructor-to-
 Text.Read.Lex.Lexeme-so.patch?

 There were a few warnings, most notably in the "`a`" variables here:
 {{{
   valueFracExp a (Just fs) mExp                         -- 4.3[e2]
     = let (a,e) = fracExp (fromMaybe 0 mExp) a fs in Exp a e
 }}}
 which I assume was intended to be:
 {{{
   valueFracExp a (Just fs) mExp                         -- 4.3[e2]
     = let (a', e) = fracExp (fromMaybe 0 mExp) a fs
       in Exp a' e
 }}}

 `num008` then finds a number of differences, for example:

 {{{
 import Numeric

 main :: IO ()
 main = mapM_ (putStrLn . f) ["4.2000000e2", "1.8217369e0",
 "1.8217369e-300"]

 f :: String -> String
 f str = let d :: Double
             d = read str
         in str ++ replicate (15 - length str) ' ' ++ show d
 }}}

 Before the patch:
 {{{
 $ ghc --make q
 [1 of 1] Compiling Main             ( q.hs, q.o )
 Linking q ...
 $ ./q
 4.2000000e2    420.0
 1.8217369e0    1.8217369
 1.8217369e-300 1.8217369e-300
 }}}

 After the patch:
 {{{
 $ ghc --make q
 [1 of 1] Compiling Main             ( q.hs, q.o )
 Linking q ...
 $ ./q
 4.2000000e2    420.00000000000006
 1.8217369e0    1.8217368999999999
 1.8217369e-300 1.8217368999999997e-300
 }}}

 Are we happy with that?

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

_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

Reply via email to