assertions are turned off if -O2 comes after -fno-ignore-asserts
test.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.