Skip to content

Commit 4210cca

Browse files
authored
Use read_unaligned instead of read in transmute_copy
Closes: #55044 This change could result in performance regression on non-x86 platforms. Alternative would be to update `transmute_copy` with alignment requirements.
1 parent 8f19cad commit 4210cca

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libcore/mem.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ pub fn drop<T>(_x: T) { }
818818
#[inline]
819819
#[stable(feature = "rust1", since = "1.0.0")]
820820
pub unsafe fn transmute_copy<T, U>(src: &T) -> U {
821-
ptr::read(src as *const T as *const U)
821+
ptr::read_unaligned(src as *const T as *const U)
822822
}
823823

824824
/// Opaque type representing the discriminant of an enum.

0 commit comments

Comments
 (0)