]> git.lizzy.rs Git - rust.git/commitdiff
Use correct alignment checks for scalars and zsts, too
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Thu, 15 Nov 2018 17:05:15 +0000 (18:05 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Sat, 24 Nov 2018 10:36:32 +0000 (11:36 +0100)
src/librustc_mir/interpret/operand.rs

index 61c3c6f24ffb8a68f4f7ad0b64a8b0d7469d56fa..4ec01b6ca1032e28810b0ff5bc390ad901524aaa 100644 (file)
@@ -271,13 +271,13 @@ pub(super) fn try_read_immediate_from_mplace(
         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