Ticket #4105 (new bug)
ffi005 fails on OS X
| Reported by: | igloo | Owned by: | |
|---|---|---|---|
| Priority: | low | Milestone: | 7.6.2 |
| Component: | Compiler | Version: | 6.12.2 |
| Keywords: | Cc: | ||
| Operating System: | MacOS X | Architecture: | Unknown/Multiple |
| Type of failure: | None/Unknown | Difficulty: | |
| Test Case: | ffi005 | Blocked By: | |
| Blocking: | Related Tickets: |
Description
The ffi005 test is failing on OS X x86.
The test is only run the optc way, but we get other bad results when compiling in other ways.
normal:
{-# LANGUAGE ForeignFunctionInterface #-}
import Control.Monad
import Foreign.C
main :: IO ()
main = doit sin mysin (encodeFloat 7926335344172077 (-54))
doit :: (CDouble -> CDouble) -> (CDouble -> CDouble) -> CDouble -> IO ()
doit f g x = do let fx = f x
gx = g x
when (fx /= gx) $ do print x
print (decodeFloat x)
print fx
print gx
print (fx - gx)
foreign import ccall "sin" mysin :: CDouble -> CDouble
$ ghc q.hs -o q; ./q 0.4400000000000002 (7926335344172077,-54) 0.4259394650659998 0.42593946506599983 -5.551115123125783e-17
optc:
{-# LANGUAGE ForeignFunctionInterface #-}
import Control.Monad
import Foreign
import Foreign.C
main :: IO ()
main = do sin_addr <- wrapId sin
doit sin (dyn_sin sin_addr) (encodeFloat 7926335344172077 (-54))
freeHaskellFunPtr sin_addr
doit :: (CDouble -> CDouble) -> (CDouble -> CDouble) -> CDouble -> IO ()
doit f g x = do let fx = f x
gx = g x
when (fx /= gx) $ do print x
print (decodeFloat x)
print fx
print gx
print (fx - gx)
foreign import ccall "wrapper" wrapId :: (CDouble -> CDouble) -> IO (FunPtr (CDouble -> CDouble))
foreign import ccall "dynamic" dyn_sin :: FunPtr (CDouble -> CDouble) -> (CDouble -> CDouble)
$ ghc w.hs -o w -fvia-c -O; ./w 0.4400000000000002 (7926335344172077,-54) 0.42593946506599983 0.4259394650659998 5.551115123125783e-17
optasm:
{-# LANGUAGE ForeignFunctionInterface #-}
import Control.Monad
import Foreign
import Foreign.C
main :: IO ()
main = do sin_addr <- wrapId sin
doit sin (dyn_sin sin_addr) (encodeFloat 7926335344172077 (-54))
freeHaskellFunPtr sin_addr
doit :: (CDouble -> CDouble) -> (CDouble -> CDouble) -> CDouble -> IO ()
doit f g x = do let fx = f x
gx = g x
when (fx /= gx) $ do print x
print (decodeFloat x)
print fx
print gx
print (decodeFloat fx)
print (decodeFloat gx)
print (fx == gx)
print (decodeFloat fx == decodeFloat gx)
print (fx - gx)
foreign import ccall "wrapper" wrapId :: (CDouble -> CDouble) -> IO (FunPtr (CDouble -> CDouble))
foreign import ccall "dynamic" dyn_sin :: FunPtr (CDouble -> CDouble) -> (CDouble -> CDouble)
$ ghc r.hs -o r -O; ./r 0.4400000000000002 (7926335344172077,-54) 0.4259394650659998 0.4259394650659998 (7673043264614500,-54) (7673043264614500,-54) False True 0.0
Change History
Note: See
TracTickets for help on using
tickets.
