state hack causes unneeded value to be evaluated
The following code prints "Main: Why?
" when compiled with ghc -O1
. With -fno-state-hack
it works fine.
data X = X ()
{-# NOINLINE newX #-}
newX :: () -> IO X
newX n = do
let {-# NOINLINE value #-}
value = n
return (X value)
main = do
x <- newX (error "Why?")
case x of
X _ -> return ()
Both pragmas are needed to exhibit the bug.
(In my actual code, value
is an unsafePerformIO
-- this was the motivation for adding the pragmas.)
Trac metadata
Trac field | Value |
---|---|
Version | 6.10.1 |
Type | Bug |
TypeOfFailure | OtherFailure |
Priority | normal |
Resolution | Unresolved |
Component | Compiler |
Test case | |
Differential revisions | |
BlockedBy | |
Related | |
Blocking | |
CC | |
Operating system | |
Architecture |