]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/concurrency/thread_local_static_dealloc.rs
Auto merge of #101030 - woppopo:const_location, r=scottmcm
[rust.git] / src / tools / miri / tests / fail / concurrency / thread_local_static_dealloc.rs
1 //! Ensure that thread-local statics get deallocated when the thread dies.
2
3 #![feature(thread_local)]
4
5 #[thread_local]
6 static mut TLS: u8 = 0;
7
8 struct SendRaw(*const u8);
9 unsafe impl Send for SendRaw {}
10
11 fn main() {
12     unsafe {
13         let dangling_ptr = std::thread::spawn(|| SendRaw(&TLS as *const u8)).join().unwrap();
14         let _val = *dangling_ptr.0; //~ ERROR: dereferenced after this allocation got freed
15     }
16 }