You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
staticmutFLAG:bool = false;fnmain(){let p = std::ptr::addr_of!(FLAG);println!("{p:p}")}
I expected this to compile without adding an unsafe block, since the act of getting the address of the static on its own cannot(?) cause Undefined Behavior. Making addr_of! and addr_of_mut! safe when used on a static mut would make the behavior consistent with UnsafeCell::get, which has identical safety concerns in a multithreaded environment.
Meta
Exists on stable and the nightly version used by playground (2024-05-30).