]> git.lizzy.rs Git - rust.git/blob - src/test/run-make-fulldeps/foreign-double-unwind/foo.rs
Rollup merge of #98525 - JohnTitor:issue-79224, r=compiler-errors
[rust.git] / src / test / run-make-fulldeps / foreign-double-unwind / foo.rs
1 // Tests that C++ double unwinding through Rust code will be properly guarded
2 // against instead of exhibiting undefined behaviour.
3
4 #![feature(c_unwind)]
5
6 extern "C-unwind" {
7     fn throw_cxx_exception();
8     fn cxx_catch_callback(cb: extern "C-unwind" fn());
9 }
10
11 struct ThrowOnDrop;
12
13 impl Drop for ThrowOnDrop {
14     fn drop(&mut self) {
15         unsafe { throw_cxx_exception() };
16     }
17 }
18
19 extern "C-unwind" fn test_double_unwind() {
20     let _a = ThrowOnDrop;
21     let _b = ThrowOnDrop;
22 }
23
24 fn main() {
25     unsafe { cxx_catch_callback(test_double_unwind) };
26 }