diff options
Diffstat (limited to 'tests/codegen-llvm/issues/no-bounds-check-after-assert-110971.rs')
| -rw-r--r-- | tests/codegen-llvm/issues/no-bounds-check-after-assert-110971.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/codegen-llvm/issues/no-bounds-check-after-assert-110971.rs b/tests/codegen-llvm/issues/no-bounds-check-after-assert-110971.rs new file mode 100644 index 00000000000..aa4002f176d --- /dev/null +++ b/tests/codegen-llvm/issues/no-bounds-check-after-assert-110971.rs @@ -0,0 +1,14 @@ +// Tests that the slice access for `j` doesn't have a bounds check panic after +// being asserted as less than half of the slice length. + +//@ compile-flags: -Copt-level=3 + +#![crate_type = "lib"] + +// CHECK-LABEL: @check_only_assert_panic +#[no_mangle] +pub fn check_only_assert_panic(arr: &[u32], j: usize) -> u32 { + // CHECK-NOT: panic_bounds_check + assert!(j < arr.len() / 2); + arr[j] +} |
