-
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
caution against ptr-to-int transmutes #95547
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r? @scottmcm (rust-highfive has picked a reviewer for you, use r? to override) |
rust-highfive
added
the
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
label
Apr 1, 2022
RalfJung
force-pushed
the
ptr-int-transmutes
branch
from
April 2, 2022 15:19
a7b204c
to
dd85a76
Compare
This was referenced Apr 2, 2022
Since I don't think this is making any new promises and it being "preferrable" to avoid @bors r+ rollup We have lots of time to tweak the messaging before even going to beta, if anyone else has strong feelings. |
📌 Commit dd85a76 has been approved by |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Apr 5, 2022
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Apr 5, 2022
Rollup of 8 pull requests Successful merges: - rust-lang#88025 (ScmCredentials netbsd implementation.) - rust-lang#95473 (track individual proc-macro expansions in the self-profiler) - rust-lang#95547 (caution against ptr-to-int transmutes) - rust-lang#95585 (Explain why `&T` is cloned when `T` is not `Clone`) - rust-lang#95591 (Use revisions to track NLL test output (part 1)) - rust-lang#95663 (diagnostics: give a special note for unsafe fn / Fn/FnOnce/FnMut) - rust-lang#95673 (:arrow_up: rust-analyzer) - rust-lang#95681 (resolve: Fix resolution of empty paths passed from rustdoc) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
A-strict-provenance
Area: Strict provenance for raw pointers
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I don't know how strong of a statement we want to make here, but I am very concerned that the current docs could be interpreted as saying that ptr-to-int transmutes are just as okay as transmuting
*mut T
into an&mut T
.Examples like this show that ptr-to-int transmutes are deeply suspicious -- they are either UB, or they don't round-trip properly, or we have to basically say that
transmute
will actively look for pointers and do all the things a ptr-to-int cast does (which includes a global side-effect of marking the pointed-to allocation as 'exposed').Another alternative might be to simply not talk about them... but we do want people to use casts rather than transmutes for this.
Cc @rust-lang/lang