Skip to content

Commit 6c5c48e

Browse files
committedApr 2, 2024
Check that nested statics in thread locals are duplicated per thread.
1 parent e2cf2cb commit 6c5c48e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
 
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// Check that nested statics in thread locals are
2+
// duplicated per thread.
3+
4+
#![feature(const_refs_to_cell)]
5+
#![feature(thread_local)]
6+
7+
//@run-pass
8+
9+
#[thread_local]
10+
static mut FOO: &mut u32 = &mut 42;
11+
12+
fn main() {
13+
unsafe {
14+
*FOO = 1;
15+
16+
let _ = std::thread::spawn(|| {
17+
assert_eq!(*FOO, 42);
18+
*FOO = 99;
19+
})
20+
.join();
21+
22+
assert_eq!(*FOO, 1);
23+
}
24+
}

0 commit comments

Comments
 (0)