`transmute_copy` should not have alignment requirements
Closed this issue · 4 comments
arielb1 commented
std::mem::transmute_copy should work on unaligned pointers, unlike dereferences and ptr::read.
Amanieu commented
newpavlov commented
This issue is fixed, see the referenced issue.
RalfJung commented
It turns out indeed that transmute_copy uses read_unaligned. I had no idea. That might be worth calling out in its documentation?
Note that the reference still needs to be T-aligned, as all references do. But it does not have to be U-aligned.
newpavlov commented
It was changed in rust-lang/rust#55052.