rust/tests/fail/concurrency/windows_join_detached.rs

22 lines
473 B
Rust
Raw Normal View History

2022-07-15 03:40:06 -05:00
//@only-target-windows: Uses win32 api functions
//@error-pattern: Undefined Behavior: trying to join a detached thread
// Joining a detached thread is undefined behavior.
use std::os::windows::io::{AsRawHandle, RawHandle};
use std::thread;
extern "system" {
fn CloseHandle(handle: RawHandle) -> u32;
}
fn main() {
let thread = thread::spawn(|| ());
unsafe {
assert_ne!(CloseHandle(thread.as_raw_handle()), 0);
}
thread.join().unwrap();
}