
#12614: Integer division can overwrite other arguments to foreign call
-------------------------------------+-------------------------------------
Reporter: jscholl | Owner:
Type: bug | Status: new
Priority: normal | Milestone:
Component: Compiler | Version: 8.0.1
(NCG) |
Keywords: integer | Operating System: Unknown/Multiple
division |
Architecture: x86_64 | Type of failure: Incorrect result
(amd64) | at runtime
Test Case: | Blocked By:
Blocking: | Related Tickets:
Differential Rev(s): | Wiki Page:
-------------------------------------+-------------------------------------
If you call a foreign function, GHC can generate incorrect code while
passing the arguments to the function, overwriting the 3rd argument if a
later argument contains an integer division.
Main.hs:
{{{
{-# LANGUAGE ForeignFunctionInterface #-}
module Main where
{-# NOINLINE foo #-}
foo :: Int -> IO ()
foo x = c_foo 0 0 x $ x + x `quot` 10
foreign import ccall "foo" c_foo :: Int -> Int -> Int -> Int -> IO ()
main :: IO ()
main = do
foo 202
foo 203
foo 204
}}}
foo.c:
{{{
#include