#5557: Code using seq has wrong strictness (too lazy)
---------------------------------+------------------------------------------
Reporter: michal.palka | Owner:
Type: bug | Status: new
Priority: normal | Component: Compiler
Version: 7.2.1 | Keywords: seq strictness strict lazy
Testcase: | Blockedby:
Os: Unknown/Multiple | Blocking:
Architecture: Unknown/Multiple | Failure: Incorrect result at runtime
---------------------------------+------------------------------------------
Following snippet of code gets miscompiled regardless of optimisation
level:
{{{
([seq (seq (tail ([]::[Int])) (\a -> error "aaa"))] !! 0) [1]
}}}
The result of printing the value is `[1]`, whereas the correct result
should be throwing an error:
{{{
testModule: Prelude.tail: empty list
}}}
The same problem occurs if I try to run the code in GHCI.
Looking at the Core at -O0 suggests that the expression with two `seq`s
gets transformed into the identity function, despite that `tail []` could
(and will) crash. Since the problem is visible in Core, I mark this bug as
independent of the architecture.
I tried it in GHC versions 7.2.1 and 7.3.20111013, which gave same wrong
results.
--
Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/5557>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
_______________________________________________
Glasgow-haskell-bugs mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs