Closed
Description
I tried this code with -C overflow-checks=off
:
#[allow(arithmetic_overflow)]
fn main() {
i32::MIN % -1;
i32::MIN / -1;
}
I expected to see this happen: It does not panic since overflow checks are disabled, and per the reference this doesn't panic when overflow checks are disabled
Instead, this happened: It panics with attempt to calculate the remainder with overflow
Meta
rustc --version --verbose
:
$ rustc +local --version --verbose
rustc 1.54.0-dev
binary: rustc
commit-hash: unknown
commit-date: unknown
host: x86_64-unknown-linux-gnu
release: 1.54.0-dev
LLVM version: 12.0.1
Backtrace
thread 'main' panicked at 'attempt to calculate the remainder with overflow', ov.rs:3:5
stack backtrace:
0: rust_begin_unwind
at /home/smit/rustc-dev/rust/library/std/src/panicking.rs:515:5
1: core::panicking::panic_fmt
at /home/smit/rustc-dev/rust/library/core/src/panicking.rs:92:14
2: core::panicking::panic
at /home/smit/rustc-dev/rust/library/core/src/panicking.rs:50:5
3: ov::main
4: core::ops::function::FnOnce::call_once
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
I'm not sure if the issue is with rustc
or the reference here.