]> git.lizzy.rs Git - rust.git/blob - tests/codegen/enum-bounds-check-issue-82871.rs
Auto merge of #107843 - bjorn3:sync_cg_clif-2023-02-09, r=bjorn3
[rust.git] / tests / codegen / enum-bounds-check-issue-82871.rs
1 // compile-flags: -C opt-level=0
2
3 #![crate_type = "lib"]
4
5 #[repr(C)]
6 pub enum E {
7     A,
8 }
9
10 // CHECK-LABEL: @index
11 #[no_mangle]
12 pub fn index(x: &[u32; 3], ind: E) -> u32 {
13     // Canary: we should be able to optimize out the bounds check, but we need
14     // to track the range of the discriminant result in order to be able to do that.
15     // oli-obk tried to add that, but that caused miscompilations all over the place.
16     // CHECK: panic_bounds_check
17     x[ind as usize]
18 }