[GHC] #6156: Optimiser bug on linux-powerpc
GHC
cvs-ghc at haskell.org
Wed Aug 22 10:49:29 CEST 2012
#6156: Optimiser bug on linux-powerpc
------------------------------------------+---------------------------------
Reporter: erikd | Owner: igloo
Type: bug | Status: new
Priority: normal | Milestone: 7.6.1
Component: Compiler | Version: 7.4.1
Resolution: | Keywords:
Os: Linux | Architecture: powerpc
Failure: Incorrect result at runtime | Difficulty: Unknown
Testcase: | Blockedby:
Blocking: | Related:
------------------------------------------+---------------------------------
Comment(by erikd):
Thanks @simonmar, thats a good tip. Using the FFI:
{{{
import Foreign.C.Types
import Numeric
foreign import ccall "c_printInt64" printInt64 :: CLLong -> IO ()
main :: IO ()
main = do
printInt64 input
putStrLn (showHex input "")
input :: CLLong
input = 0x1a2a3a4a5a6a7a8a
}}}
and compiled without optimisation I get:
{{{
1a2a3a4a5a6a7a8a
1a2a3a4a5a6a7a8a
}}}
and with optimisation I get:
{{{
7a8a
1a2a3a4a5a6a7a8a
}}}
which is weird in that the FFI version is incorrect, but only when
optimisation is off.
Modifying this example as:
{{{
import Foreign.C.Types
import Numeric
foreign import ccall "c_printInt64" printInt64 :: CLLong -> IO ()
main :: IO ()
main = do
printInt64 (succ input)
putStrLn (showHex (succ input) "")
input :: CLLong
input = 0x1a2a3a4a5a6a7a8a
}}}
and then both the FFI and the pure Haskell version are incorrect with
optimisation.
This suggests that its actually a problem with the way 64 bit values are
passed to functions.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/6156#comment:38>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the Glasgow-haskell-bugs
mailing list