-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it UB to change a non-mut
extern static
?
#514
Comments
Part of my intention with the Unsafe Extern Blocks RFC (rust-lang/rfcs#3484) is that, other than the problem of making type signatures match, an extern and a rust native function/static should behave the same. So, I don't know the current state of it, but I'd say that this should be a UB case. If the extern static can be mutated, then it needs a type signature that reflects that. |
Yes. |
Closing since rust-lang/reference#1502 is merged. |
Is it UB to change a non-
mut
non-UnsafeCell
extern
static
, outside of Rust land?Obviously it is UB to change it from Rust, but is it UB to change it from other. But is it UB to also change it from external code?
For instance, is the following UB?
Rust:
C:
LLVM does not optimize the return value of
do_work()
to betrue
(https://godbolt.org/z/xdqGM839n), and we also don't tell it it is constant (we say@foo = external global i32
). So this probably isn't UB from LLVM. But still, is it UB in the Rust AM?The Reference does not hint in any way that this might be UB. It says the following about external
static
s:The text was updated successfully, but these errors were encountered: