Skip to content

Code using seq has wrong strictness when unoptimised (too lazy)

The code code should crash with Prelude.undefined. When compiled with -O it behaves correctly, however with no optimisation (-O0) it prints [0] instead. Reading the Core suggests that the expression gets translated into print (id [0]) when compiled with -O0. It was tested with GHC 7.3.20111022.

main = do
  let a = \x -> seq undefined (+1)
  print $ (a `seq` a [] `seq` id) [0]
Trac metadata
Trac field Value
Version 7.3
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution Unresolved
Component Compiler
Test case
Differential revisions
BlockedBy
Related
Blocking
CC michal.palka@poczta.fm
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information