-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
The offset_of!
macro may need to be a compiler intrinsic
#48956
Comments
Existing crates implementing
(Also, there should be an |
Why do we even need a memory location for that? Can't we just create a raw pointer from the ether and operate on that? https://play.rust-lang.org/?gist=79229d888ce819235d5350241a037a78&version=stable |
Perhaps! I recall some discussion in the past about how valid the temporary reference is there, but I'd naively assume that such a construction was reasonable! |
I guess @rust-lang/lang would have to answer this, but I think the answer is "yes". We've had some things around this area like https://internals.rust-lang.org/t/pre-rfc-add-a-new-offset-of-macro-to-core-mem/9273 |
Given that we have had rust-lang/rfcs#3308 and now have the |
This came up a few weeks ago in libs triage specifically related to #48493 where we were wondering if there were other locations in the standard library that needed to be adjusted to handle uninhabited enums being handled in generic locations. While not many locations in the standard library leapt to mind one thing we thought of was the
offset_of!
macro.For example if we've got something like:
do existing
offset_of!
macros handle this?or is there "technical UB that rustc may paper over today" somewhere in there?
cc @dtolnay, I think you had better ideas about examples here than I!
The text was updated successfully, but these errors were encountered: