Skip to content

Commit 4fb3c4b

Browse files
authored
Fix handling of large alignments in write_cvalue_maybe_transmute (#1521)
1 parent b70ad2d commit 4fb3c4b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/value_and_place.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,10 @@ impl<'tcx> CPlace<'tcx> {
677677
let to_addr = to_ptr.get_addr(fx);
678678
let src_layout = from.1;
679679
let size = dst_layout.size.bytes();
680-
let src_align = src_layout.align.abi.bytes() as u8;
681-
let dst_align = dst_layout.align.abi.bytes() as u8;
680+
// `emit_small_memory_copy` uses `u8` for alignments, just use the maximum
681+
// alignment that fits in a `u8` if the actual alignment is larger.
682+
let src_align = src_layout.align.abi.bytes().try_into().unwrap_or(128);
683+
let dst_align = dst_layout.align.abi.bytes().try_into().unwrap_or(128);
682684
fx.bcx.emit_small_memory_copy(
683685
fx.target_config,
684686
to_addr,

0 commit comments

Comments
 (0)