Skip to content

Commit

Permalink
fix mplace_access_checked with forced alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed May 18, 2021
1 parent 563ab4a commit d5ccf68
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions compiler/rustc_mir/src/interpret/place.rs
Expand Up @@ -374,8 +374,9 @@ where
.size_and_align_of_mplace(&place)?
.unwrap_or((place.layout.size, place.layout.align.abi));
assert!(place.mplace.align <= align, "dynamic alignment less strict than static one?");
// Check (stricter) dynamic alignment, unless forced otherwise.
place.mplace.align = force_align.unwrap_or(align);
let align = force_align.unwrap_or(align);
// Record new (stricter, unless forced) alignment requirement in place.
place.mplace.align = align;
// When dereferencing a pointer, it must be non-null, aligned, and live.
if let Some(ptr) = self.memory.check_ptr_access(place.ptr, size, align)? {
place.mplace.ptr = ptr.into();
Expand Down

0 comments on commit d5ccf68

Please sign in to comment.