@@ -278,7 +278,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
278
278
"miri_get_alloc_id" => {
279
279
let [ ptr] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
280
280
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| {
282
282
err_machine_stop ! ( TerminationInfo :: Abort ( format!(
283
283
"pointer passed to `miri_get_alloc_id` must not be dangling, got {ptr:?}"
284
284
) ) )
@@ -311,7 +311,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
311
311
"miri_static_root" => {
312
312
let [ ptr] = this. check_shim ( abi, Abi :: Rust , link_name, args) ?;
313
313
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 ) ?;
315
315
if offset != Size :: ZERO {
316
316
throw_unsup_format ! (
317
317
"pointer passed to `miri_static_root` must point to beginning of an allocated block"
@@ -392,7 +392,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
392
392
"`miri_promise_symbolic_alignment`: pointer is not actually aligned"
393
393
) ;
394
394
}
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 ) {
396
396
let ( _size, alloc_align, _kind) = this. get_alloc_info ( alloc_id) ;
397
397
// If the newly promised alignment is bigger than the native alignment of this
398
398
// allocation, and bigger than the previously promised alignment, then set it.
@@ -584,8 +584,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
584
584
let n = Size :: from_bytes ( this. read_target_usize ( n) ?) ;
585
585
586
586
// 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 ) ?;
589
589
590
590
let result = {
591
591
let left_bytes = this. read_bytes_ptr_strip_provenance ( left, n) ?;
@@ -612,7 +612,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
612
612
let val = val as u8 ;
613
613
614
614
// 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 ) ?;
616
616
617
617
if let Some ( idx) = this
618
618
. read_bytes_ptr_strip_provenance ( ptr, Size :: from_bytes ( num) ) ?
@@ -622,7 +622,7 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
622
622
{
623
623
let idx = u64:: try_from ( idx) . unwrap ( ) ;
624
624
#[ 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) ;
626
626
this. write_pointer ( new_ptr, dest) ?;
627
627
} else {
628
628
this. write_null ( dest) ?;
@@ -639,14 +639,14 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
639
639
let val = val as u8 ;
640
640
641
641
// 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 ) ?;
643
643
644
644
let idx = this
645
645
. read_bytes_ptr_strip_provenance ( ptr, Size :: from_bytes ( num) ) ?
646
646
. iter ( )
647
647
. position ( |& c| c == val) ;
648
648
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) ;
650
650
this. write_pointer ( new_ptr, dest) ?;
651
651
} else {
652
652
this. write_null ( dest) ?;
@@ -681,8 +681,8 @@ trait EvalContextExtPriv<'tcx>: crate::MiriInterpCxExt<'tcx> {
681
681
682
682
// C requires that this must always be a valid pointer, even if `n` is zero, so we better check that.
683
683
// (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 ) ?;
686
686
687
687
this. mem_copy ( ptr_src, ptr_dest, Size :: from_bytes ( n) , true ) ?;
688
688
this. write_pointer ( ptr_dest, dest) ?;
0 commit comments