-
Notifications
You must be signed in to change notification settings - Fork 356
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
Fixes for align_offset #957
Conversation
5449e9c
to
f736636
Compare
Thanks! @bors r+ |
📌 Commit e2c54e6 has been approved by |
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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we also have a more direct test that immediately calls align_offset
? That seems useful to have.
☀️ Test successful - checks-travis, status-appveyor |
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).
|
I don't see how that relates? We could have something that creates a |
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 addresses @RalfJung's comments in #945