From c8450bda4fc3ed70aa019f83c58ff8ee8f9fcb09 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 3 Jul 2019 09:56:35 +0200 Subject: [PATCH] support integers that can be cast to pointers in in-bounds offset operation --- src/operator.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/operator.rs b/src/operator.rs index 219448431683..2e9b8238479f 100644 --- a/src/operator.rs +++ b/src/operator.rs @@ -397,7 +397,7 @@ impl<'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'mir, 'tcx> { .checked_mul(pointee_size) .ok_or_else(|| InterpError::Overflow(mir::BinOp::Mul))?; // Now let's see what kind of pointer this is. - if let Scalar::Ptr(ptr) = ptr { + if let Ok(ptr) = self.force_ptr(ptr) { // Both old and new pointer must be in-bounds of a *live* allocation. // (Of the same allocation, but that part is trivial with our representation.) self.pointer_inbounds(ptr)?; @@ -405,7 +405,7 @@ impl<'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'mir, 'tcx> { self.pointer_inbounds(ptr)?; Ok(Scalar::Ptr(ptr)) } else { - // An integer pointer. They can only be offset by 0, and we pretend there + // A "true" integer pointer. They can only be offset by 0, and we pretend there // is a little zero-sized allocation here. if offset == 0 { Ok(ptr)