Ticket #2756 (closed merge: fixed)
state hack causes unneeded value to be evaluated
| Reported by: | int-e | Owned by: | igloo |
|---|---|---|---|
| Priority: | normal | Milestone: | 6.10.2 |
| Component: | Compiler | Version: | 6.10.1 |
| Keywords: | Cc: | ||
| Operating System: | Unknown/Multiple | Architecture: | Unknown/Multiple |
| Type of failure: | Difficulty: | Unknown | |
| Test Case: | simplCore/should_run/T2756 | Blocked By: | |
| Blocking: | Related Tickets: |
Description
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.)
Change History
Note: See
TracTickets for help on using
tickets.
