-
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
Document what a "dangling pointer" is #132286
Comments
cc @rust-lang/opsem |
Also see rust-lang/unsafe-code-guidelines#478 (but note that some things changed since the issue was opened so part of the information there is outdated). |
The reference has a definition of dangling pointers. |
Right, so somewhat confusingly |
The documentation for |
Documentation from the reference:
This implies that a pointer points to a range of addresses, depending on the type, and whether a pointer is dangling depends on the type. Documentation from
This implies that whether a pointer is dangling or not doesn't depend on the type. These two definitions are contradictory. |
"may potentially" is definitely true, it doesn't say "will always" after all. But yeah "is dangling" in the
We need to choose a different term for one of these. |
I just realized that |
But Cc @rust-lang/libs-api in case they disagree |
That's a good point. The lint name however can still be changed (even after 1.84). |
Location
There are several places this applies, e.g.:
std::ptr::dangling
std::ptr::from_ref
(in the examples)dangling_pointers_from_temporaries
lintSummary
We have several place in the standard library or as part of lints where we use the term "dangling pointer" without defining it anywhere.
We should have a place where we define what that is, ideally in the standard library, in it's own section, maybe under
std::ptr
, so it can be referenced elsewhere.It should probably have a definition, followed by some bad examples (and maybe how to fix them).
Wikipedia has article on the subject, I don't know if it could serve as a base for our documentation but it may be worth checking it.
Steps
The text was updated successfully, but these errors were encountered: