-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Description
Transmuting bytes to an arbitrary type can cause undefined behavior.
The safety requirements:
Tmust beSized.- The length of bytes must be equal to
size_of::<T>(). - The alignment of bytes must be equal to
align_of::<T>(). Tmust be valid for any binary representation.
Lines 367 to 369 in 57c05e1
| let val_array: Box<[u8]> = val.into_boxed_slice(); | |
| let val_raw: *mut T = Box::into_raw(val_array) as *mut T; | |
| let val_box: Box<T> = unsafe { Box::from_raw(val_raw) }; |
Metadata
Metadata
Assignees
Labels
No labels