Skip to content

Commit 77e27a0

Browse files
committed
Auto merge of #1744 - rust-lang:bad-unwind, r=RalfJung
ensure we catch incorrectly unwinding calls Fixes #1740
2 parents ae96420 + c9ff02f commit 77e27a0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// error-pattern: calling a function with ABI C-unwind using caller ABI C
2+
#![feature(c_unwind)]
3+
4+
//! Unwinding when the caller ABI is "C" (without "-unwind") is UB.
5+
//! Currently we detect the ABI mismatch; we could probably allow such calls in principle one day
6+
//! but then we have to detect the unexpected unwinding.
7+
8+
extern "C-unwind" fn unwind() {
9+
panic!();
10+
}
11+
12+
fn main() {
13+
let unwind: extern "C-unwind" fn() = unwind;
14+
let unwind: extern "C" fn() = unsafe { std::mem::transmute(unwind) };
15+
std::panic::catch_unwind(|| unwind()).unwrap_err();
16+
}

0 commit comments

Comments
 (0)