Different behavior for --cfg debug_assertions versus -C debug_assertions #116673
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The following two commands have different behavior:
RUSTFLAGS="--cfg debug_assertions" cargo run --release
RUSTFLAGS="-C debug_assertions" cargo run --release
1 does not enable integer overflow checks (and alignment checks), while 2 does. The rustc Codegen docs that mention "overflow checks are enabled if debug-assertions are enabled, disabled otherwise", do not apply to the --cfg debug_assertions version.
This can be tested using this small program:
I'm not sure if this just needs a documentation update, or something more substantial like prohibiting usage of
--cfg debug_assertions
without also setting-C debug_assertions
(à la rust-lang/compiler-team#610). Either way, it seems like a sharp edge that could trip people up.The text was updated successfully, but these errors were encountered: