Closed
Conversation
06a411b to
a614f5f
Compare
Makes progress on #170
a614f5f to
19f1bdc
Compare
jswrenn
reviewed
Aug 29, 2023
Comment on lines
+950
to
+951
| /// The all-zeroes const and mut raw pointers are valid, and it is sound to | ||
| /// materialize them from nothing. The existence of `ptr::null` [1] and |
Collaborator
There was a problem hiding this comment.
Is it clearly documented anywhere that 0 is a valid value for the null pointer? Infamously, the C standard does not require that null pointers have an all-zero bit-pattern, only that they compare as equal to 0.
Comment on lines
+979
to
+980
| unsafe_impl!(T: Sized => FromZeroes for *const T); | ||
| unsafe_impl!(T: Sized => FromZeroes for *mut T); |
Collaborator
There was a problem hiding this comment.
This snippet from the internals of the standard library gives me pause:
pub const fn invalid<T>(addr: usize) -> *const T {
// FIXME(strict_provenance_magic): I am magic and should be a compiler intrinsic.
// We use transmute rather than a cast so tools like Miri can tell that this
// is *not* the same as from_exposed_addr.
// SAFETY: every valid integer is also a valid pointer (as long as you don't dereference that
// pointer).
unsafe { mem::transmute(addr) }
}The use of mem::transmute suggests that these sorts of transmutes are fine now, but what about the comment "I am magic and should be a compiler intrinsic"?
Member
Author
|
Current plan is to wait until this change (or something similar) lands so the soundness of this PR is clearly backed by the Rust reference. |
Member
Author
|
Closing in favor of #584. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Makes progress on #170