#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:43 igloo]:
 > Replying to [comment:41 igloo]:
 > > but the second and third should break (I'm not sure what they should
 return. Whichever of Infinity, -Infinity, NaN and 0.0 best fits the
 implementation, I guess).
 >
 > Or perhaps if the exponent is `> FLT_MAX_EXP`, `< FLT_MIN_EXP`, `>
 DBL_MAX_EXP` or `< DBL_MIN_EXP` then read should fail?

 It seems the "e"-Notation is really (exponentially expanding) syntactic
 sugar for a plain decimal number (without e), i.e. the bits of the
 internal floats are not set directly.

 In this case, just checking the exponent against MAX_EXP and MIN_EXP is
 not enough. The length of the leading fractional needs to be considered,
 too, i.e. for extreme examples like "1000000000000000000e-1022" or
 "0.00000000000000000000001e1023".

 I vote for that reading should not fail, but return +/- (sign preserving)
 Infinity or 0.0. (What case should return NaN? I think, no case.)

 Reading long integers as int does not fail, too!

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