Opened 10 years ago

Closed 10 years ago

Last modified 46 years ago

#464 closed bug (Fixed)

Control.Exception.assert broken with -O

Reported by: fergus Owned by: nobody
Priority: normal Milestone:
Component: libraries/base Version: 6.4.1
Keywords: Cc:
Operating System: Architecture:
Type of failure: Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):


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
"-fignore-asserts", and the "-O" option should have no
effect on them.

But in ghc version, "-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

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

Change History (1)

comment:1 Changed 10 years ago by simonmar

  • Status changed from assigned to closed
Logged In: YES 

The documentation does actually mention that
-fignore-asserts is turned on by -O (section 4.9.2), but
section 7.8 doesn't make any mention of it.  I've now fixed
this.  Thanks for the report.
Note: See TracTickets for help on using tickets.