-
Notifications
You must be signed in to change notification settings - Fork 0
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
Causes UB by creating NULL reference #1
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a heads-up that the crate does not compile any more with the current Rust beta (to become stable Nov 7th). The reason is that there is UB in this const-code:
vptr/macros/macros.rs
Line 125 in ca32aa4
References must always be non-null, dereferencable and aligned as well as point to a valid instance of
T
(see the Rust Reference for details). Violating that invariant is UB, and it is the responsibility of theunsafe
code author to ensure that there is no UB.Unfortunately, there never was a UB-free way to implement
offsetof!
in Rust. This operation is just not supported by the language right now, and the only way to fix that is to figure out what needs to change in the language to let Rust support this operation, and write an appropriate RFC. I did that and that RFC has in fact recently been accepted, but an implementation is still pending.The
memoffset
crate uses an approach that's as good as we can currently make it, and we know it works with current compilers (including the latest nightly), but it could break any time as it, too, is outside the bounds of stable Rust. Also, the approach it uses does not work for CTFE; enabling that is still work-in-progress.Is there a way for this crate to do the offset computation at run-time instead of trying to do it at compile-time? Then it could depend on
memoffset
to avoid this problem. I'm afraid for compile-timeoffsetof
there is currently no solution.The text was updated successfully, but these errors were encountered: