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

Comment(by maeder):

 Replying to [comment:49 igloo]:
 > `fracExp` in `libraries/base/Text/Read/Lex.hs` makes the `Rational`, and
 `fromRational` in `libraries/base/GHC/Float.lhs` converts the `Rational`
 to a `Double/Float`.

 Computing the possibly big Rational when reading is wrong in my eyes. The
 Lexeme must store the fraction and (optional) exponent separately! Only
 when converting to a floating point type you know how many digits in the
 exponent may make sense. (`Float.lhs` is incomprehensible for me, but it
 may do the right thing.)

 (An alternative is to set a fixed limit of 6 digits in the exponent,
 because more cannot be handled.)

 Going via Rational is bad for bigger floating point numbers. The right
 thing would be to compute the arguments for `encodeFloat` during
 conversion.

-- 
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5688#comment:52>
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