mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 19:58:32 +00:00
fix mplace_access_checked with forced alignment
This commit is contained in:
parent
563ab4a106
commit
d5ccf68a10
@ -374,8 +374,9 @@ where
|
|||||||
.size_and_align_of_mplace(&place)?
|
.size_and_align_of_mplace(&place)?
|
||||||
.unwrap_or((place.layout.size, place.layout.align.abi));
|
.unwrap_or((place.layout.size, place.layout.align.abi));
|
||||||
assert!(place.mplace.align <= align, "dynamic alignment less strict than static one?");
|
assert!(place.mplace.align <= align, "dynamic alignment less strict than static one?");
|
||||||
// Check (stricter) dynamic alignment, unless forced otherwise.
|
let align = force_align.unwrap_or(align);
|
||||||
place.mplace.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.
|
// 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)? {
|
if let Some(ptr) = self.memory.check_ptr_access(place.ptr, size, align)? {
|
||||||
place.mplace.ptr = ptr.into();
|
place.mplace.ptr = ptr.into();
|
||||||
|
Loading…
Reference in New Issue
Block a user