summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/panic/bad_unwind.rs
blob: 370b372a7d373822c5d04f6a9d66289b243ae619 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#![feature(c_unwind)]

//! Unwinding when the caller ABI is "C" (without "-unwind") is UB.

extern "C-unwind" fn unwind() {
    panic!();
}

fn main() {
    let unwind: extern "C-unwind" fn() = unwind;
    let unwind: extern "C" fn() = unsafe { std::mem::transmute(unwind) };
    std::panic::catch_unwind(|| unwind()).unwrap_err();
    //~^ ERROR: unwinding past a stack frame that does not allow unwinding
}