-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Documentation for addr_of_mut!
is contradictory
#94473
Comments
Why do you think that is the case? |
Thanks, I didn't realize that was allowed. Getting a good handle on what is and isn't allowed with pointers in Rust is not always super easy :) Is there an existing piece of documentation that spells out what all the rules are? It would be great to hyperlink |
Yeah, it's all kind of complicated. ;) Basically the core rules are these ones. |
Explicitly list the things you aren't allowed to do with `expr`, and add a link to the exact definition of a dangling pointer. Fixes rust-lang#94473
Closing this. I think #114902 covers it pretty well :) |
The documentation for
addr_of_mut!
says:However, in the example for
Creating a pointer to uninitialized data
it shows this code:In that example it appears as though
expr
contains a dereference of uninitialized data, which is not normally valid. That seems in conflict with the earlier warning that "all the usual rules" apply.I'm guessing that maybe dereferencing is allowed in
expr
as long as the pointer isn't dangling?The text was updated successfully, but these errors were encountered: