
#12656: ghci floats out constant despite -fno-cse, resulting in very unintuitive behaviour -------------------------------------+------------------------------------- Reporter: nh2 | Owner: Type: bug | Status: new Priority: normal | Milestone: Component: Compiler | Version: 8.0.1 Keywords: | Operating System: Unknown/Multiple Architecture: | Type of failure: Incorrect result Unknown/Multiple | at runtime Test Case: | Blocked By: Blocking: | Related Tickets: Differential Rev(s): | Wiki Page: -------------------------------------+------------------------------------- Consider this program using `Data.Vector.unsafeThaw` and `-fno-cse`: {{{ {-# OPTIONS_GHC -fno-cse #-} import qualified Data.Vector as V import qualified Data.Vector.Mutable as VM main :: IO () main = do foo 100000 foo 100000 foo :: Int -> IO () foo n = do indexVector <- V.unsafeThaw $ V.generate n id x <- VM.read indexVector 5 VM.write indexVector 5 (x * x) print x -- In GHCI, we get: -- -- > :set -fno-cse -- -- > foo 100000 -- 5 -- > foo 100000 -- 5 -- -- > let f = foo 100000 in f >> f -- 5 -- 25 }}} I would expect that {{{
let f = foo 100000 in f >> f 5 5 }}}
Shouldn't `-fno-cse` fix this? (Note: With `ghc` instead of `ghci`, we don't observe this behaviour.) -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/12656 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler