-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-const-propArea: Constant propagationArea: Constant propagationA-control-flowArea: Control flowArea: Control flowA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-const-propArea: Constant propagationArea: Constant propagationA-control-flowArea: Control flowArea: Control flowA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.