about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2018-11-15 18:05:15 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2018-11-24 11:36:32 +0100
commit9b8e82ad242ba438b0db983248c59281b4355891 (patch)
tree819a991d8b91254c8fbb2c7ecccb4054768b24a1
parent927c5aab47c624fe9f4cf02289a2acccd425432c (diff)
downloadrust-9b8e82ad242ba438b0db983248c59281b4355891.tar.gz
rust-9b8e82ad242ba438b0db983248c59281b4355891.zip
Use correct alignment checks for scalars and zsts, too
-rw-r--r--src/librustc_mir/interpret/operand.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/librustc_mir/interpret/operand.rs b/src/librustc_mir/interpret/operand.rs
index 61c3c6f24ff..4ec01b6ca10 100644
--- a/src/librustc_mir/interpret/operand.rs
+++ b/src/librustc_mir/interpret/operand.rs
@@ -271,13 +271,13 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M>
         if mplace.layout.is_zst() {
             // Not all ZSTs have a layout we would handle below, so just short-circuit them
             // all here.
-            self.memory.check_align(ptr, ptr_align)?;
+            self.memory.check_align(ptr, ptr_align.min(mplace.layout.align))?;
             return Ok(Some(Immediate::Scalar(Scalar::zst().into())));
         }
 
         // check for integer pointers before alignment to report better errors
         let ptr = ptr.to_ptr()?;
-        self.memory.check_align(ptr.into(), ptr_align)?;
+        self.memory.check_align(ptr.into(), ptr_align.min(mplace.layout.align))?;
         match mplace.layout.abi {
             layout::Abi::Scalar(..) => {
                 let scalar = self.memory