]> git.proxmox.com Git - rustc.git/blame - tests/codegen/enum-bounds-check-issue-82871.rs
New upstream version 1.72.1+dfsg1
[rustc.git] / tests / codegen / enum-bounds-check-issue-82871.rs
CommitLineData
064997fb 1// compile-flags: -C opt-level=0
6a06907d
XL
2
3#![crate_type = "lib"]
4
5#[repr(C)]
6pub enum E {
7 A,
8}
9
10// CHECK-LABEL: @index
11#[no_mangle]
064997fb
FG
12pub 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
6a06907d
XL
17 x[ind as usize]
18}