Rollup merge of #129666 - RalfJung:raw-eq-align, r=compiler-errors
interpret: add missing alignment check in raw_eq The intrinsic requires alignment, but we forgot to check for that in Miri and const-eval.
This commit is contained in:
commit
5c2996d750
3 changed files with 20 additions and 6 deletions
|
@ -684,19 +684,19 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
|
|||
assert!(layout.is_sized());
|
||||
|
||||
let get_bytes = |this: &InterpCx<'tcx, M>,
|
||||
op: &OpTy<'tcx, <M as Machine<'tcx>>::Provenance>,
|
||||
size|
|
||||
op: &OpTy<'tcx, <M as Machine<'tcx>>::Provenance>|
|
||||
-> InterpResult<'tcx, &[u8]> {
|
||||
let ptr = this.read_pointer(op)?;
|
||||
let Some(alloc_ref) = self.get_ptr_alloc(ptr, size)? else {
|
||||
this.check_ptr_align(ptr, layout.align.abi)?;
|
||||
let Some(alloc_ref) = self.get_ptr_alloc(ptr, layout.size)? else {
|
||||
// zero-sized access
|
||||
return Ok(&[]);
|
||||
};
|
||||
alloc_ref.get_bytes_strip_provenance()
|
||||
};
|
||||
|
||||
let lhs_bytes = get_bytes(self, lhs, layout.size)?;
|
||||
let rhs_bytes = get_bytes(self, rhs, layout.size)?;
|
||||
let lhs_bytes = get_bytes(self, lhs)?;
|
||||
let rhs_bytes = get_bytes(self, rhs)?;
|
||||
Ok(Scalar::from_bool(lhs_bytes == rhs_bytes))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue