Creating a raw pointer to an external static requires an unsafe block #74843
Labels
A-FFI
Area: Foreign function interface (FFI)
C-bug
Category: This is a bug.
F-raw_ref_op
`#![feature(raw_ref_op)]`
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I tried this code (playground):
I expected to see this happen: it compile and print the address of
FOO
twice.Instead, this happened: compilation failed because accessing
FOO
requires anunsafe
blockAs far as I can tell none of the potential causes of UB can be caused by just creating a raw pointer to the static. This should be a safe operation, and only when attempting to use the pointer in the future should you need to prove validity of it.
The text was updated successfully, but these errors were encountered: