[GHC] #11555: catch under unsafePerformIO breaks on -O1 (was: catch _|_ breaks at -O1)
GHC
ghc-devs at haskell.org
Mon Feb 8 14:46:16 UTC 2016
#11555: catch under unsafePerformIO breaks on -O1
-------------------------------------+-------------------------------------
Reporter: slyfox | Owner:
Type: bug | Status: new
Priority: highest | Milestone: 8.0.1
Component: Compiler | Version: 8.0.1-rc2
Resolution: | 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: |
-------------------------------------+-------------------------------------
Comment (by rwbarton):
It is fallout from #11222, but it's not a bug. There's no guarantee that
the ''pure value'' passed to `catch` will be evaluated at any particular
time. `catch` catches exceptions that arise from the ''execution'' of its
IO argument action.
Correct versions of this program would include changing `abort` to `abort
:: Stack -> IO a; abort x = throwIO $ ...` or changing `C.catch (abort
"fail")` to `C.catch (evaluate (abort "fail"))`. But I'm not sure that
there is any way currently to, given an (unevaluated) IO action, evaulate
it and execute it, catching exceptions raised by either step. A possible
attempt would be `catch (do { a <- evaluate action; a })`, but would GHC
see through this?
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11555#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list