#3676: realToFrac doesn't sanely convert between floating types
----------------------------------+-----------------------------------------
Reporter: draconx | Owner:
Type: bug | Status: new
Priority: normal | Milestone: 6.12.2
Component: libraries (other) | Version: 6.12.1
Keywords: | Difficulty:
Os: Unknown/Multiple | Testcase:
Architecture: x86_64 (amd64) | Failure: None/Unknown
----------------------------------+-----------------------------------------
Changes (by draconx):
* version: 6.10.4 => 6.12.1
Comment:
Still present in 6.12.1.
I just discovered that the issue is worse than originally described: the
behaviour of realToFrac *changes* if it gets inlined. Consider the
following:
{{{
module Main where
{-# NOINLINE holycow #-}
holycow :: (Real a, Fractional b) => a -> b
holycow = realToFrac
main = do
print (realToFrac (0/0 :: Double) :: Double)
print (holycow (0/0 :: Double) :: Double)
}}}
If you compile without optimisation, both lines print -Infinity as
originally described. However, if you enable optimisation, the first line
prints NaN (yay!) but the second line still prints -Infinity. GHC seems
to be optimising based on the incorrect assumption that realToFrac ::
Double -> Double is the identity function.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/3676#comment:4>
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