2021-11-14 02:08:12 +00:00
|
|
|
//@ only-x86_64
|
|
|
|
//@ run-pass
|
|
|
|
//@ needs-asm-support
|
2022-09-12 22:42:04 +00:00
|
|
|
//@ needs-unwind
|
2021-11-14 02:08:12 +00:00
|
|
|
|
2022-10-17 21:38:37 +00:00
|
|
|
#![feature(asm_unwind)]
|
2021-11-14 02:08:12 +00:00
|
|
|
|
2021-12-10 00:15:33 +00:00
|
|
|
use std::arch::asm;
|
2021-11-14 02:08:12 +00:00
|
|
|
use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe};
|
|
|
|
|
|
|
|
struct Foo<'a>(&'a mut bool);
|
|
|
|
|
|
|
|
impl Drop for Foo<'_> {
|
|
|
|
fn drop(&mut self) {
|
|
|
|
*self.0 = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" fn panicky() {
|
|
|
|
resume_unwind(Box::new(()));
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let flag = &mut true;
|
|
|
|
catch_unwind(AssertUnwindSafe(|| {
|
|
|
|
let _foo = Foo(flag);
|
2021-11-28 20:52:27 +00:00
|
|
|
unsafe {
|
|
|
|
asm!(
|
|
|
|
"call {}",
|
|
|
|
sym panicky,
|
|
|
|
clobber_abi("C"),
|
|
|
|
options(may_unwind)
|
|
|
|
);
|
|
|
|
}
|
2021-11-14 02:08:12 +00:00
|
|
|
}))
|
|
|
|
.expect_err("expected a panic");
|
|
|
|
assert_eq!(*flag, false);
|
|
|
|
}
|