Miri: fix alignment check in array initialization
This commit is contained in:
parent
686e313a9a
commit
f8e3b31858
1 changed files with 5 additions and 1 deletions
|
@ -242,11 +242,15 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||||
let elem_size = first.layout.size;
|
let elem_size = first.layout.size;
|
||||||
let first_ptr = first.ptr;
|
let first_ptr = first.ptr;
|
||||||
let rest_ptr = first_ptr.offset(elem_size, self)?;
|
let rest_ptr = first_ptr.offset(elem_size, self)?;
|
||||||
|
// For the alignment of `rest_ptr`, we crucially do *not* use `first.align` as
|
||||||
|
// that place might be more aligned than its type mandates (a `u8` array could
|
||||||
|
// be 4-aligned if it sits at the right spot in a struct). Instead we use
|
||||||
|
// `first.layout.align`, i.e., the alignment given by the type.
|
||||||
self.memory.copy_repeatedly(
|
self.memory.copy_repeatedly(
|
||||||
first_ptr,
|
first_ptr,
|
||||||
first.align,
|
first.align,
|
||||||
rest_ptr,
|
rest_ptr,
|
||||||
first.align,
|
first.layout.align.abi,
|
||||||
elem_size,
|
elem_size,
|
||||||
length - 1,
|
length - 1,
|
||||||
/*nonoverlapping:*/ true,
|
/*nonoverlapping:*/ true,
|
||||||
|
|
Loading…
Add table
Reference in a new issue