diff options
| author | beetrees <b@beetr.ee> | 2024-07-21 12:13:58 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-21 13:13:58 +0200 |
| commit | 4fb3c4bf863f2ab32fee13405f71b6785763e909 (patch) | |
| tree | 50c6964247b7e322de33c01c61dacd849381038b | |
| parent | b70ad2defd4bb5fba6af7958893e22be0f33dfdd (diff) | |
| download | rust-4fb3c4bf863f2ab32fee13405f71b6785763e909.tar.gz rust-4fb3c4bf863f2ab32fee13405f71b6785763e909.zip | |
Fix handling of large alignments in `write_cvalue_maybe_transmute` (#1521)
| -rw-r--r-- | src/value_and_place.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/value_and_place.rs b/src/value_and_place.rs index 1aa28daeafc..8eb2095e523 100644 --- a/src/value_and_place.rs +++ b/src/value_and_place.rs @@ -677,8 +677,10 @@ impl<'tcx> CPlace<'tcx> { let to_addr = to_ptr.get_addr(fx); let src_layout = from.1; let size = dst_layout.size.bytes(); - let src_align = src_layout.align.abi.bytes() as u8; - let dst_align = dst_layout.align.abi.bytes() as u8; + // `emit_small_memory_copy` uses `u8` for alignments, just use the maximum + // alignment that fits in a `u8` if the actual alignment is larger. + let src_align = src_layout.align.abi.bytes().try_into().unwrap_or(128); + let dst_align = dst_layout.align.abi.bytes().try_into().unwrap_or(128); fx.bcx.emit_small_memory_copy( fx.target_config, to_addr, |
