Open
Description
Is the following code sound?
thread_local! {
static X: String = String::from("abc");
}
/// SAFETY: If this function is called in a certain thread,
/// then the returned reference must not be used after
/// the "top-level function" of that thread finishes.
unsafe fn smuggle() -> &'static String {
&*X.with(|a| a as *const String)
}
In other words, is it guaranteed that:
- A thread-local's address is stable?
- &mut references won't be created to thread-locals until it's time to run thread-local destructors?
Metadata
Metadata
Assignees
Labels
No labels