Closed
Description
STR:
$ cargo new testcase ; cd testcase
$ cat <<EOF > src/main.rs
fn main() {
let a = [0; 2];
let b = unsafe { a.get_unchecked(3) };
println!("{}", b);
}
EOF
$ cargo +nightly run -q
32764
$ cargo +nightly run -q -Zbuild-std --target=x86_64-unknown-linux-gnu
thread 'main' panicked at /home/glandium/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/slice/index.rs:228:9:
slice::get_unchecked requires that the index is within the slice
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread caused non-unwinding panic. aborting.
It would seem the intent is for the latter to always happen, but it doesn't.
$ rustc +nightly --version
rustc 1.77.0-nightly (cb4d9a190 2024-01-30)