Re: [GHC] #7411: Exceptions are optimized away in certain situations

#7411: Exceptions are optimized away in certain situations -------------------------------------+------------------------------------- Reporter: SimonHengel | Owner: tdammers Type: bug | Status: new Priority: high | Milestone: 8.6.1 Component: Compiler | Version: 7.6.1 Resolution: | Keywords: seq, deepseq, | evaluate, exceptions Operating System: Linux | Architecture: x86_64 | (amd64) Type of failure: Incorrect result | Test Case: at runtime | simplCore/should_fail/T7411 Blocked By: | Blocking: Related Tickets: #5129 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by tdammers): OK, boiled it down to a simpler test case that doesn't even involve `deepseq`: {{{ import Control.Exception dslist :: [a] -> b -> b dslist xs b = go xs `seq` b where go [] = () go (x:xs) = x `seq` go xs -- the following variation also reproduces the problem: -- go (x:xs) = go (x `seq` xs) main = evaluate (('a':undefined) `dslist` return () :: IO ()) }}} This is essentially what `deepseq` does on lists, with all the typeclass instances and type variables manually unrolled. Note that in order to trigger the bug, we actually do need the `go` function; if instead we pass the `b` around and recurse directly, the problem goes away, like so: {{{ import Control.Exception dslist :: [a] -> b -> b dslist xs b = go xs `seq` b where dslist [] a = a dslist (x:xs) a = x `seq` dslist xs a main = evaluate (('a':undefined) `dslist` return () :: IO ()) }}} -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/7411#comment:22 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler
participants (1)
-
GHC