[GHC] #2756: state hack causes unneeded value to be evaluated
GHC
trac at galois.com
Sun Nov 9 21:56:46 EST 2008
#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
More information about the Glasgow-haskell-bugs
mailing list