Open
Description
I tried this code:
fn main() {
let v: [i32; 0] = [];
let _ = v.len() > 0 && v[0] == 0;
}
I expected to see this happen: code compiles and runs fine, without any error or panic
Instead, this happened:
error: this operation will panic at runtime
--> t.rs:3:28
|
3 | let _ = v.len() > 0 && v[0] == 0;
| ^^^^ index out of bounds: the length is 0 but the index is 0
|
= note: `#[deny(unconditional_panic)]` on by default
Meta
rustc --version --verbose
:
rustc 1.56.0
binary: rustc
commit-hash: unknown
commit-date: unknown
host: armv7-linux-androideabi
release: 1.56.0
LLVM version: 13.0.0