Hacker News new | ask | show | jobs
by dxhdr 986 days ago
> But if your assertion checks don't run in release mode, and due to some bug, those invariants don't hold, well, your program is already going to exhibit undefined behaviour. Why not let the compiler know about the undefined behaviour so it can optimize better?

Usually in release mode you want to log the core dump and then fix the bug.

1 comments

Yeah; thats why I like rust's approach. You can either leave assertions in in release mode, so you get your core dump. Or you can take them out if you're confident they won't fire in order to make the program faster.

The unreachable pragma suggested by the author is just a more extreme version of the latter choice.