Skip to content

Commit 9b8e82a

Browse files
committed
Use correct alignment checks for scalars and zsts, too
1 parent 927c5aa commit 9b8e82a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/librustc_mir/interpret/operand.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,13 +271,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
271271
if mplace.layout.is_zst() {
272272
// Not all ZSTs have a layout we would handle below, so just short-circuit them
273273
// all here.
274-
self.memory.check_align(ptr, ptr_align)?;
274+
self.memory.check_align(ptr, ptr_align.min(mplace.layout.align))?;
275275
return Ok(Some(Immediate::Scalar(Scalar::zst().into())));
276276
}
277277

278278
// check for integer pointers before alignment to report better errors
279279
let ptr = ptr.to_ptr()?;
280-
self.memory.check_align(ptr.into(), ptr_align)?;
280+
self.memory.check_align(ptr.into(), ptr_align.min(mplace.layout.align))?;
281281
match mplace.layout.abi {
282282
layout::Abi::Scalar(..) => {
283283
let scalar = self.memory

0 commit comments

Comments
 (0)