diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-08-28 17:12:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-28 17:12:19 +0200 |
| commit | 5c2996d750a9a6a65ea4e5d3133be1f8f6b80ad1 (patch) | |
| tree | f4ce811cb1cd1b67fdcc50e21880eddf8745d686 /compiler/rustc_const_eval/src | |
| parent | 29188a54b3320b427dfefd67a3bb299ad2ea524e (diff) | |
| parent | e17be955bbd5c0fa6e95805a2cb96946262cd75b (diff) | |
| download | rust-5c2996d750a9a6a65ea4e5d3133be1f8f6b80ad1.tar.gz rust-5c2996d750a9a6a65ea4e5d3133be1f8f6b80ad1.zip | |
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.
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/intrinsics.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/intrinsics.rs b/compiler/rustc_const_eval/src/interpret/intrinsics.rs index aef39b9af2f..bedc56de0da 100644 --- a/compiler/rustc_const_eval/src/interpret/intrinsics.rs +++ b/compiler/rustc_const_eval/src/interpret/intrinsics.rs @@ -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)) } } |
