cargo-aoc
cargo-aoc copied to clipboard
Run with debug-assertions and overflow-checks turned on
This is some-what similar to #18, where the debug symbols are turned on, but there are quite a few other differences between the dev and release profiles.
Certain classes of bugs are ignored in the release profile, and it makes finding them difficult. The easiest thing to do would be add the following to the profile if a flag is turned on.
debug-assertions = true
overflow-checks = true
The overflow checks are really useful to make sure you aren't overflowing on a multiplication step that is common at the end. The debug-assertion, makes sure that you aren't doing something dumb that would normally be caught.
The release profile disables them compared to the dev profile.
As a workaround, you can set the environment variable CARGO_PROFILE_RELEASE_OVERFLOW_CHECKS = "true" to enable overflow checks. There might be something similar for debug assertions. You might be able to get it to work with a RUSTFLAGS setting too.
According to https://doc.rust-lang.org/cargo/reference/environment-variables.html#configuration-environment-variables,
The debug-assertions should be configurable with CARGO_PROFILE_RELEASE_DEBUG_ASSERTIONS = "true"
I just ran into this. A --debug flag would be nice.