[GHC] #10754: truncate /= double2Int

GHC ghc-devs at haskell.org
Fri Aug 7 13:08:37 UTC 2015


#10754: truncate /= double2Int
-------------------------------------+-------------------------------------
              Reporter:  cblp        |             Owner:
                  Type:  bug         |            Status:  new
              Priority:  normal      |         Milestone:
             Component:              |           Version:  7.10.2
  libraries/base                     |
              Keywords:  truncate,   |  Operating System:  Unknown/Multiple
  double2Int, rewrite, rule          |
          Architecture:              |   Type of failure:  Incorrect result
  Unknown/Multiple                   |  at runtime
             Test Case:              |        Blocked By:
              Blocking:              |   Related Tickets:
Differential Revisions:              |
-------------------------------------+-------------------------------------
 There is a rule in libraries/base/GHC/Float.hs:
 {{{#!hs
 "truncate/Double->Int"  truncate = double2Int
 }}}
 But it is not true for some values. Particularly,
 {{{#!hs
 let infinity = 1/0 :: Double
 truncate infinity :: Int == 0
 double2Int infinity == -9223372036854775808  -- minBound
 }}}

 As a result, the value of {{{truncate (1/0 :: Double) :: Int}}} depends on
 optimization level.

--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/10754>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list