@@ -262,7 +262,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
262262 Scalar :: Ptr ( ptr) => {
263263 // check this is not NULL -- which we can ensure only if this is in-bounds
264264 // of some (potentially dead) allocation.
265- let align = self . check_bounds_ptr_maybe_dead ( ptr) ?;
265+ let align = self . check_bounds_ptr ( ptr, InboundsCheck :: MaybeDead ) ?;
266266 ( ptr. offset . bytes ( ) , align)
267267 }
268268 Scalar :: Bits { bits, size } => {
@@ -297,17 +297,15 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
297297 /// Check if the pointer is "in-bounds". Notice that a pointer pointing at the end
298298 /// of an allocation (i.e., at the first *inaccessible* location) *is* considered
299299 /// in-bounds! This follows C's/LLVM's rules.
300- /// This function also works for deallocated allocations.
301- /// Use `.get(ptr.alloc_id)?.check_bounds_ptr(ptr)` if you want to force the allocation
302- /// to still be live.
303300 /// If you want to check bounds before doing a memory access, better first obtain
304301 /// an `Allocation` and call `check_bounds`.
305- pub fn check_bounds_ptr_maybe_dead (
302+ pub fn check_bounds_ptr (
306303 & self ,
307304 ptr : Pointer < M :: PointerTag > ,
305+ liveness : InboundsCheck ,
308306 ) -> EvalResult < ' tcx , Align > {
309307 let ( allocation_size, align) = self . get_size_and_align ( ptr. alloc_id ) ;
310- ptr. check_in_alloc ( allocation_size, InboundsCheck :: MaybeDead ) ?;
308+ ptr. check_in_alloc ( allocation_size, liveness ) ?;
311309 Ok ( align)
312310 }
313311}
0 commit comments