rust/tests/codegen-llvm/issues/slice-index-bounds-check-80075.rs
okaneco 9e28de2720 Add codegen regression tests
Most of these regressions concern elimination of panics and bounds
checks that were fixed upstream by LLVM.
2025-08-20 22:29:45 -04:00

14 lines
344 B
Rust

// Tests that no bounds check panic is generated for `j` since
// `j <= i < data.len()`.
//@ compile-flags: -Copt-level=3
#![crate_type = "lib"]
// CHECK-LABEL: @issue_80075
#[no_mangle]
pub fn issue_80075(data: &[u8], i: usize, j: usize) -> u8 {
// CHECK-NOT: panic_bounds_check
if i < data.len() && j <= i { data[j] } else { 0 }
}