3 ms·
Good question. I think the answer is no, and that `let value = *ptr;` is UB if the pointer is misaligned. The right way to go is `let value = ptr.read_unaligned
by kzrdude 6y ago
Good question. I think the answer is no, and that `let value = *ptr;` is UB if the pointer is misaligned. The right way to go is `let value = ptr.read_unaligned();`
But the docs will say this:
> Accessing unaligned fields directly with e.g. packed.unaligned is safe however.
https://doc.rust-lang.org/nightly/std/ptr/fn.read_unaligned.html https://doc.rust-lang.org/nightly/std/ptr/fn.read_unaligned....