Skip to content

Commit c8450bd

Browse files
committed
support integers that can be cast to pointers in in-bounds offset operation
1 parent c3da843 commit c8450bd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/operator.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,15 +397,15 @@ impl<'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'mir, 'tcx> {
397397
.checked_mul(pointee_size)
398398
.ok_or_else(|| InterpError::Overflow(mir::BinOp::Mul))?;
399399
// Now let's see what kind of pointer this is.
400-
if let Scalar::Ptr(ptr) = ptr {
400+
if let Ok(ptr) = self.force_ptr(ptr) {
401401
// Both old and new pointer must be in-bounds of a *live* allocation.
402402
// (Of the same allocation, but that part is trivial with our representation.)
403403
self.pointer_inbounds(ptr)?;
404404
let ptr = ptr.signed_offset(offset, self)?;
405405
self.pointer_inbounds(ptr)?;
406406
Ok(Scalar::Ptr(ptr))
407407
} else {
408-
// An integer pointer. They can only be offset by 0, and we pretend there
408+
// A "true" integer pointer. They can only be offset by 0, and we pretend there
409409
// is a little zero-sized allocation here.
410410
if offset == 0 {
411411
Ok(ptr)

0 commit comments

Comments
 (0)