Skip to content

Control.Exception.assert broken with -O

According to the ghc documentation
(section 4.9 "optimization" and section 7.8 "assertions" in
the user guide, and the documentation for Control.Exception
in the hierarchical libraries guide),
assertions should be checked unless explicitly disabled
with
"-fignore-asserts", and the "-O" option should have no
effect on them.

But in ghc version 6.4.1.20050801, "-O" seems to also
have the
effect of disabling assertions:

   bash$ cat Test.hs
   import Control.Exception
   main = print (assert False (42::Int))

   bash$ ghc -O Test.hs && ./a.out
   42

This undocumented behaviour is an egregious violation
of the
principle of least surprise.



Trac metadata
Trac field Value
Version 6.4.1
Type Bug
TypeOfFailure OtherFailure
Priority normal
Resolution ResolvedFixed
Component libraries/base
Test case
Differential revisions
BlockedBy
Related
Blocking
CC
Operating system
Architecture
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information