mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 21:47:15 +03:00
support integers that can be cast to pointers in in-bounds offset operation
This commit is contained in:
+2
-2
@@ -397,7 +397,7 @@ fn pointer_offset_inbounds(
|
||||
.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 @@ fn pointer_offset_inbounds(
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user