Merge pull request #187 from dwrensha/fix-issue-184-mark-packed
fix issue 184 by marking the destination as a packed struct
This commit is contained in:
commit
cad0188c72
@ -383,8 +383,18 @@ pub(super) fn call_intrinsic(
|
||||
}
|
||||
|
||||
"transmute" => {
|
||||
let src_ty = substs.type_at(0);
|
||||
let dest_ty = substs.type_at(1);
|
||||
self.write_value(arg_vals[0], dest, dest_ty)?;
|
||||
let src_align = self.type_align(src_ty)?;
|
||||
let dest_align = self.type_align(dest_ty)?;
|
||||
let size = self.type_size(dest_ty)?.expect("transmute() type must be sized");
|
||||
if dest_align < src_align {
|
||||
let ptr = self.force_allocation(dest)?.to_ptr();
|
||||
self.memory.mark_packed(ptr, size);
|
||||
self.write_value_to_ptr(arg_vals[0], ptr, dest_ty)?;
|
||||
} else {
|
||||
self.write_value(arg_vals[0], dest, dest_ty)?;
|
||||
}
|
||||
}
|
||||
|
||||
"uninit" => {
|
||||
|
4
tests/run-pass/issue-miri-184.rs
Normal file
4
tests/run-pass/issue-miri-184.rs
Normal file
@ -0,0 +1,4 @@
|
||||
pub fn main() {
|
||||
let bytes: [u8; 8] = unsafe { ::std::mem::transmute(0u64) };
|
||||
let _: &[u8] = &bytes;
|
||||
}
|
Loading…
Reference in New Issue
Block a user