2021-03-14 11:03:20 -05:00
|
|
|
// error-pattern: calling a function with ABI C-unwind using caller ABI C
|
|
|
|
#![feature(c_unwind)]
|
|
|
|
|
|
|
|
//! Unwinding when the caller ABI is "C" (without "-unwind") is UB.
|
|
|
|
//! Currently we detect the ABI mismatch; we could probably allow such calls in principle one day
|
|
|
|
//! but then we have to detect the unexpected unwinding.
|
2021-05-29 12:36:06 -05:00
|
|
|
//! FIXME: `-Zmiri-disable-abi-check` does not work for this test because function pointers are
|
|
|
|
//! always allowed to unwind.
|
2021-03-14 11:03:20 -05:00
|
|
|
|
|
|
|
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();
|
|
|
|
}
|