Check that nested statics in thread locals are duplicated per thread.

This commit is contained in:
Oli Scherer 2024-04-02 12:06:52 +00:00
parent e2cf2cb303
commit 6c5c48e880

View File

@ -0,0 +1,24 @@
// Check that nested statics in thread locals are
// duplicated per thread.
#![feature(const_refs_to_cell)]
#![feature(thread_local)]
//@run-pass
#[thread_local]
static mut FOO: &mut u32 = &mut 42;
fn main() {
unsafe {
*FOO = 1;
let _ = std::thread::spawn(|| {
assert_eq!(*FOO, 42);
*FOO = 99;
})
.join();
assert_eq!(*FOO, 1);
}
}