]>
Commit | Line | Data |
---|---|---|
a2a8927a XL |
1 | // only-x86_64 |
2 | // run-pass | |
3 | // needs-asm-support | |
f2b60f7d | 4 | // needs-unwind |
a2a8927a | 5 | |
2b03887a | 6 | #![feature(asm_unwind)] |
a2a8927a XL |
7 | |
8 | use std::arch::asm; | |
9 | use std::panic::{catch_unwind, resume_unwind, AssertUnwindSafe}; | |
10 | ||
11 | struct Foo<'a>(&'a mut bool); | |
12 | ||
13 | impl Drop for Foo<'_> { | |
14 | fn drop(&mut self) { | |
15 | *self.0 = false; | |
16 | } | |
17 | } | |
18 | ||
19 | extern "C" fn panicky() { | |
20 | resume_unwind(Box::new(())); | |
21 | } | |
22 | ||
23 | fn main() { | |
24 | let flag = &mut true; | |
25 | catch_unwind(AssertUnwindSafe(|| { | |
26 | let _foo = Foo(flag); | |
27 | unsafe { | |
28 | asm!( | |
29 | "call {}", | |
30 | sym panicky, | |
31 | clobber_abi("C"), | |
32 | options(may_unwind) | |
33 | ); | |
34 | } | |
35 | })) | |
36 | .expect_err("expected a panic"); | |
37 | assert_eq!(*flag, false); | |
38 | } |