gobanos / cargo-aoc

452 stars 48 forks source link

Run with debug-assertions and overflow-checks turned on #63

Open pedantic79 opened 3 years ago

pedantic79 commented 3 years ago

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.

tocklime commented 3 years ago

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.

pedantic79 commented 3 years ago

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"

bddap commented 3 years ago

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