Opened 9 years ago

Closed 9 years ago

Last modified 44 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: Difficulty:
Test Case: Blocked By:
Blocking: Related Tickets:

Description

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.




Change History (1)

comment:1 Changed 9 years ago by simonmar

  • Status changed from assigned to closed
Logged In: YES 
user_id=48280

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.