Skip to content

Commit

Permalink
Check that nested statics in thread locals are duplicated per thread.
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Apr 2, 2024
1 parent e2cf2cb commit 6c5c48e
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/ui/statics/nested_thread_local.rs
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit 6c5c48e

Please sign in to comment.