@@ -278,7 +278,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
278278 "miri_get_alloc_id" => {
279279 let [ ptr] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
280280 let ptr = this. read_pointer ( ptr) ?;
281- let ( alloc_id, _, _) = this. ptr_get_alloc_id ( ptr) . map_err ( |_e| {
281+ let ( alloc_id, _, _) = this. ptr_get_alloc_id ( ptr, 0 ) . map_err ( |_e| {
282282 err_machine_stop ! ( TerminationInfo :: Abort ( format!(
283283 "pointer passed to `miri_get_alloc_id` must not be dangling, got {ptr:?}"
284284 ) ) )
@@ -311,7 +311,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
311311 "miri_static_root" => {
312312 let [ ptr] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
313313 let ptr = this. read_pointer ( ptr) ?;
314- let ( alloc_id, offset, _) = this. ptr_get_alloc_id ( ptr) ?;
314+ let ( alloc_id, offset, _) = this. ptr_get_alloc_id ( ptr, 0 ) ?;
315315 if offset != Size :: ZERO {
316316 throw_unsup_format ! (
317317 "pointer passed to `miri_static_root` must point to beginning of an allocated block"
@@ -392,7 +392,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
392392 "`miri_promise_symbolic_alignment`: pointer is not actually aligned"
393393 ) ;
394394 }
395- if let Ok ( ( alloc_id, offset, ..) ) = this. ptr_try_get_alloc_id ( ptr) {
395+ if let Ok ( ( alloc_id, offset, ..) ) = this. ptr_try_get_alloc_id ( ptr, 0 ) {
396396 let ( _size, alloc_align, _kind) = this. get_alloc_info ( alloc_id) ;
397397 // If the newly promised alignment is bigger than the native alignment of this
398398 // allocation, and bigger than the previously promised alignment, then set it.
@@ -584,8 +584,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
584584 let n = Size :: from_bytes ( this. read_target_usize ( n) ?) ;
585585
586586 // C requires that this must always be a valid pointer (C18 §7.1.4).
587- this. ptr_get_alloc_id ( left) ?;
588- this. ptr_get_alloc_id ( right) ?;
587+ this. ptr_get_alloc_id ( left, 0 ) ?;
588+ this. ptr_get_alloc_id ( right, 0 ) ?;
589589
590590 let result = {
591591 let left_bytes = this. read_bytes_ptr_strip_provenance ( left, n) ?;
@@ -612,7 +612,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
612612 let val = val as u8 ;
613613
614614 // C requires that this must always be a valid pointer (C18 §7.1.4).
615- this. ptr_get_alloc_id ( ptr) ?;
615+ this. ptr_get_alloc_id ( ptr, 0 ) ?;
616616
617617 if let Some ( idx) = this
618618 . read_bytes_ptr_strip_provenance ( ptr, Size :: from_bytes ( num) ) ?
@@ -622,7 +622,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
622622 {
623623 let idx = u64:: try_from ( idx) . unwrap ( ) ;
624624 #[ allow( clippy:: arithmetic_side_effects) ] // idx < num, so this never wraps
625- let new_ptr = ptr. offset ( Size :: from_bytes ( num - idx - 1 ) , this) ? ;
625+ let new_ptr = ptr. wrapping_offset ( Size :: from_bytes ( num - idx - 1 ) , this) ;
626626 this. write_pointer ( new_ptr, dest) ?;
627627 } else {
628628 this. write_null ( dest) ?;
@@ -639,14 +639,14 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
639639 let val = val as u8 ;
640640
641641 // C requires that this must always be a valid pointer (C18 §7.1.4).
642- this. ptr_get_alloc_id ( ptr) ?;
642+ this. ptr_get_alloc_id ( ptr, 0 ) ?;
643643
644644 let idx = this
645645 . read_bytes_ptr_strip_provenance ( ptr, Size :: from_bytes ( num) ) ?
646646 . iter ( )
647647 . position ( |& c| c == val) ;
648648 if let Some ( idx) = idx {
649- let new_ptr = ptr. offset ( Size :: from_bytes ( idx as u64 ) , this) ? ;
649+ let new_ptr = ptr. wrapping_offset ( Size :: from_bytes ( idx as u64 ) , this) ;
650650 this. write_pointer ( new_ptr, dest) ?;
651651 } else {
652652 this. write_null ( dest) ?;
@@ -681,8 +681,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
681681
682682 // C requires that this must always be a valid pointer, even if `n` is zero, so we better check that.
683683 // (This is more than Rust requires, so `mem_copy` is not sufficient.)
684- this. ptr_get_alloc_id ( ptr_dest) ?;
685- this. ptr_get_alloc_id ( ptr_src) ?;
684+ this. ptr_get_alloc_id ( ptr_dest, 0 ) ?;
685+ this. ptr_get_alloc_id ( ptr_src, 0 ) ?;
686686
687687 this. mem_copy ( ptr_src, ptr_dest, Size :: from_bytes ( n) , true ) ?;
688688 this. write_pointer ( ptr_dest, dest) ?;
0 commit comments