Fixes for align_offset#957
Merged
Merged
Conversation
RalfJung
reviewed
Sep 23, 2019
RalfJung
reviewed
Sep 23, 2019
RalfJung
reviewed
Sep 23, 2019
5449e9c to
f736636
Compare
Member
|
Thanks! @bors r+ |
Contributor
|
📌 Commit e2c54e6 has been approved by |
Contributor
RalfJung
reviewed
Sep 28, 2019
| unsafe { x.set_len(N) }; | ||
| let vec = vec![0x4141414141414141u64; N]; | ||
| let content = unsafe { std::slice::from_raw_parts(vec.as_ptr() as *const u8, 8 * N) }; | ||
| println!("{:?}", std::str::from_utf8(content).unwrap()); |
Member
There was a problem hiding this comment.
Do we also have a more direct test that immediately calls align_offset? That seems useful to have.
Contributor
|
☀️ Test successful - checks-travis, status-appveyor |
Contributor
Author
|
we used to but then we disabled the intptrcast part and removed it
Sent from ProtonMail mobile
…-------- Original Message --------
On Sep 28, 2019, 13:38, Ralf Jung wrote:
@RalfJung commented on this pull request.
---------------------------------------------------------------
In [tests/run-pass/aligned_utf8_check.rs](#957 (comment)):
> @@ -1,13 +1,6 @@
fn main() {
const N: usize = 10;
-
- let x = vec![0x4141u16; N];
-
- let mut y: Vec<u8> = unsafe { std::mem::transmute(x) };
- unsafe { y.set_len(2 * N) };
-
- println!("{:?}", std::str::from_utf8(&y).unwrap());
-
- let mut x: Vec<u16> = unsafe { std::mem::transmute(y) };
- unsafe { x.set_len(N) };
+ let vec = vec![0x4141414141414141u64; N];
+ let content = unsafe { std::slice::from_raw_parts(vec.as_ptr() as *const u8, 8 * N) };
+ println!("{:?}", std::str::from_utf8(content).unwrap());
Do we also have a more direct test that immediately calls align_offset? That seems useful to have.
—
You are receiving this because you authored the thread.
Reply to this email directly, [view it on GitHub](#957?email_source=notifications&email_token=AHSUMUAEBF36Q3EVYNVEMVTQL6QBVA5CNFSM4IXSUCWKYY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCGH72QQ#pullrequestreview-294649154), or [mute the thread](https://github.com/notifications/unsubscribe-auth/AHSUMUG4JBCW2WAFW76RRBDQL6QBVANCNFSM4IXSUCWA).
|
Member
|
I don't see how that relates? We could have something that creates a |
Contributor
Author
|
oh no it's not like it was mandatory or anything. I'll add it later :)
Sent from ProtonMail mobile
…-------- Original Message --------
On Sep 28, 2019, 14:19, Ralf Jung wrote:
I don't see how that relates?
We could have something that creates a Box<[u32; 4]> (should be 4-aligned on all platforms) and plays around with it a bit, like aligning some pointers in there to various alignments and see that they all behave as expected.
—
You are receiving this because you authored the thread.
Reply to this email directly, [view it on GitHub](#957?email_source=notifications&email_token=AHSUMUF2PG2XN4EX2EDFI7DQL6U3HA5CNFSM4IXSUCWKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD73AWMQ#issuecomment-536218418), or [mute the thread](https://github.com/notifications/unsubscribe-auth/AHSUMUHBG5BF6VJAYQZMPVLQL6U3HANCNFSM4IXSUCWA).
|
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.
This addresses @RalfJung's comments in #945