-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Null fat pointers #66316
Comments
We have previously decided that Rust's |
@cuviper But that's a raw pointer. It should only be UB when dereferenced @eddyb Reading the last url you gave it seems the answer is yes. I find it very hard to reason about, as raw pointers in rust are usually sound no matter what you do unless you dereference |
See also rust-lang/unsafe-code-guidelines#166 |
Github should add a facepalm emoji |
There's more than just dereferencing to worry about here. It would appear to me that, by requiring the vtable pointer to be non-null, we enable a niche optimization on Edit: or wait, does it? I'm perhaps too tired to reason about it right now.... |
I am closing this in favor of the UCG issue (rust-lang/unsafe-code-guidelines#166). I don't think we're in a position to decide these things on rust-lang/rust issues; the UCG process for now is the best way to provide feedback on these issues. |
Hi,
Currently if you want a null fat pointer you need to do something like this:
which isn't fun and take a while to find.
I see 2 ways of implementing this in libcore:
1:
The problem is that the second currently isn't possible in a
const fn
. it requires making bothzeroed()
andassume_init()
const fn
s, which is physically possible (by making ~4-5 functionsconst fn
, the only problem there is thedebug_assert
inwrite_bytes
)But I don't know what's the safety consequences of using intrinsics in
const fn
.If it is safe I can start PRing some of these functions to be
const fn
.The text was updated successfully, but these errors were encountered: