fix AsByteSliceMut using raw pointers with bad provenance#780
Merged
dhardy merged 2 commits intorust-random:masterfrom Apr 20, 2019
Merged
fix AsByteSliceMut using raw pointers with bad provenance#780dhardy merged 2 commits intorust-random:masterfrom
dhardy merged 2 commits intorust-random:masterfrom
Conversation
Member
|
LGTM but I think you have a few more tweaks to add before merging. |
Contributor
Author
|
Do you want me to add RalfJung@8303309? |
Contributor
Author
|
Indeed that commit is the only other change I need to make all test suites pass (except for I also have some patches to make running Miri on the test suite feasible; I will submit those separately. |
42c840b to
d9c611f
Compare
Merged
Member
|
These look good to me thanks! Yes, |
Contributor
Author
|
Okay, so this is ready to get merged then? |
bjorn3
reviewed
Mar 7, 2020
| if cfg!(any(target_arch = "x86", target_arch = "x86_64")) { | ||
| // requires little-endian CPU supporting unaligned reads: | ||
| unsafe { *(&results[index] as *const u32 as *const u64) } | ||
| let ptr: *const u64 = results[index..index+1].as_ptr() as *const u64; |
Contributor
There was a problem hiding this comment.
This range still only covers 1 element, not 2 elements, as it uses .. instead of ..=.
Contributor
There was a problem hiding this comment.
Didn't notice that commit :)
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.
&mut slice[0] as *mut _is a raw pointer that can only be used for the first element.slice.as_mut_ptr()is not only shorter, but also correctly returns a pointer that can be used for the entire slice.(Found by running the test suite in Miri.)