[GHC] #14659: assertions are turned off if -O2 comes after -fno-ignore-asserts

GHC ghc-devs at haskell.org
Wed Jan 10 14:03:17 UTC 2018


#14659: assertions are turned off if -O2 comes after -fno-ignore-asserts
-------------------------------------+-------------------------------------
        Reporter:  mwotton           |                Owner:  (none)
            Type:  bug               |               Status:  new
        Priority:  normal            |            Milestone:
       Component:  Compiler          |              Version:  8.2.2
      Resolution:                    |             Keywords:
Operating System:  Unknown/Multiple  |         Architecture:
                                     |  Unknown/Multiple
 Type of failure:  None/Unknown      |            Test Case:
      Blocked By:                    |             Blocking:
 Related Tickets:                    |  Differential Rev(s):
       Wiki Page:                    |
-------------------------------------+-------------------------------------
Description changed by mwotton:

Old description:

> test.hs:
>
> {{{#!hs
> import Control.Exception
>
> main = assert False (return ())
> }}}
>
> ➜  ~ rm test; rm test.o; stack ghc -- -fno-ignore-asserts -O2 test.hs;
> ./test && echo $?
> [1 of 1] Compiling Main             ( test.hs, test.o )
> Linking test ...
> 0
> ➜  ~ rm test; rm test.o; stack ghc -- -O2 -fno-ignore-asserts  test.hs;
> ./test && echo $?
> [1 of 1] Compiling Main             ( test.hs, test.o )
> Linking test ...
> test: Assertion failed
> CallStack (from HasCallStack):
>   assert, called at test.hs:3:8 in main:Main
> ```
>
> tested with ghc 8.0.2 and 8.2.2.
>
> would have expected -fno-ignore-asserts to override -O2, no matter where
> it is in the options list.
> https://twitter.com/AlecMuffett/status/950699975767482370 shows how
> dangerous this could be.

New description:

 test.hs:

 {{{#!hs
 import Control.Exception

 main = assert False (return ())
 }}}
 {{{
 ➜  ~ rm test; rm test.o; stack ghc -- -fno-ignore-asserts -O2 test.hs;
 ./test && echo $?
 [1 of 1] Compiling Main             ( test.hs, test.o )
 Linking test ...
 0
 ➜  ~ rm test; rm test.o; stack ghc -- -O2 -fno-ignore-asserts  test.hs;
 ./test && echo $?
 [1 of 1] Compiling Main             ( test.hs, test.o )
 Linking test ...
 test: Assertion failed
 CallStack (from HasCallStack):
   assert, called at test.hs:3:8 in main:Main
 }}}

 tested with ghc 8.0.2 and 8.2.2.

 would have expected -fno-ignore-asserts to override -O2, no matter where
 it is in the options list.
 https://twitter.com/AlecMuffett/status/950699975767482370 shows how
 dangerous this could be.

--

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/14659#comment:1>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler


More information about the ghc-tickets mailing list