cargo-aoc icon indicating copy to clipboard operation
cargo-aoc copied to clipboard

Run with debug-assertions and overflow-checks turned on

Open pedantic79 opened this issue 5 years ago • 3 comments

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.

pedantic79 avatar Dec 03 '20 18:12 pedantic79

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.

tocklime avatar Dec 17 '20 21:12 tocklime

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"

pedantic79 avatar Dec 17 '20 21:12 pedantic79

I just ran into this. A --debug flag would be nice.

bddap avatar Nov 28 '21 19:11 bddap