1
Fork 0

(un)aligned

This commit is contained in:
Ralf Jung 2018-08-31 17:02:39 +02:00
parent dc2237c49f
commit b463871df5

View file

@ -748,8 +748,8 @@ pub unsafe fn write<T>(dst: *mut T, src: T) {
/// // Take a reference to a 32-bit integer which is not aligned. /// // Take a reference to a 32-bit integer which is not aligned.
/// let unaligned = &mut x.unaligned as *mut u32; /// let unaligned = &mut x.unaligned as *mut u32;
/// ///
/// // Dereferencing normally will emit an unaligned store instruction, /// // Dereferencing normally will emit an aligned store instruction,
/// // causing undefined behavior. /// // causing undefined behavior because the pointer is not aligned.
/// // *unaligned = v; // ERROR /// // *unaligned = v; // ERROR
/// ///
/// // Instead, use `write_unaligned` to write improperly aligned values. /// // Instead, use `write_unaligned` to write improperly aligned values.