#2756: state hack causes unneeded value to be evaluated
---------------------------------+------------------------------------------
Reporter: int-e | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 6.10.1 | Severity: normal
Keywords: | Testcase:
Architecture: Unknown/Multiple | Os: Unknown/Multiple
---------------------------------+------------------------------------------
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.)
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/2756>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs