[GHC] #11555: catch _|_ breaks at -O1
GHC
ghc-devs at haskell.org
Mon Feb 8 17:03:43 UTC 2016
#11555: catch _|_ breaks at -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 simonpj):
So consider
{{{
f x = catch (g x) <recovery-code>
}}}
where `g` is strict in `x`; perhaps
{{{
g x = if x>0 then <something> else <something else>
}}}
Now, are we allowed to use call-by-value on `f`? If 'no' then we are
forced to use lazy evaluation and thunk creation in inner loops of the I/O
system (for example). This can have a very material performance impact.
Being able do to this sort of code motion is what "The semantics of
imprecise exceptions" was all about and, combined with `unsafePerformIO`,
you can indeed get unpredictable behaviour.
There certainly ought to be a way of saying "evaluate this free variable
right at this point",and there is: `evaluate` is just what you need.
Indeed if you replace `abort "fail"` with `evaluate (abort "fail")` then
the program behaves the same no matter how you compile it.
But, I grant you, this makes my head hurt, and needs a careful writeup.
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/11555#comment:8>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list