Ticket #7034 (closed bug: fixed)

Opened 11 months ago

Last modified 11 months ago

reading a large double results in zero with ghc-7.4.2

Reported by: maeder Owned by: pcapriotti
Priority: normal Milestone: 7.6.1
Component: Compiler Version: 7.4.2
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Difficulty: Unknown
Test Case: T7034 Blocked By:
Blocking: Related Tickets: #5692

Description

Prelude> read "1E100000000000000000000" :: Double
Infinity
Prelude> read "1E1000000000000000000000" :: Double
0.0

This was probably introduced by the fix for #5688. Note that #3897 is still open.

Prelude> 1E1000000000000000000000 :: Double

takes too long and sometimes results in 0.0 or in a memory crash

Change History

Changed 11 months ago by maeder

It seems that the exponent is parsed as Int without checking overflow

Prelude> 100000000000000000000 :: Int
1661992960
Prelude> 1000000000000000000000 :: Int
-559939584

Changed 11 months ago by pcapriotti

  • owner set to pcapriotti
  • difficulty set to Unknown

Thanks for the report.

Changed 11 months ago by pcapriotti

  • milestone set to 7.6.1

Changed 11 months ago by pcapriotti

  • status changed from new to closed
  • testcase set to T7034
  • resolution set to fixed
  • related set to #5692

Fixed by:

commit 4226bae42fdd666c15190ac2f8784547d3fbad5f
Author: Paolo Capriotti <p.capriotti@gmail.com>
Date:   Mon Jul 2 12:54:57 2012 +0100

    Fix parsing of RealFloat with huge exponents (#7034).
    
    Ensure numberToRangedRational returns Nothing immediately if the
    exponent is outside Int range, so that we avoid an integer overflow
    later.

This only covers the failure for read in base.

The failure in the lexer is tracked by #5692.

Note: See TracTickets for help on using tickets.