Skip to content

Commit

Permalink
Auto merge of rust-lang#2153 - RalfJung:ptr-invalid, r=RalfJung
Browse files Browse the repository at this point in the history
with permissive-provenance set, we already treat ptr::invalid correctly

(same for strict provenance, but there it is not surprising)
  • Loading branch information
bors committed May 24, 2022
2 parents 22c97b3 + fcf3bc2 commit 5063880
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/compile-fail/provenance/ptr_invalid.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// compile-flags: -Zmiri-permissive-provenance
#![feature(strict_provenance)]

// Ensure that a `ptr::invalid` ptr is truly invalid.
fn main() {
let x = 42;
let xptr = &x as *const i32;
let xptr_invalid = std::ptr::invalid::<i32>(xptr.expose_addr());
let _val = unsafe { *xptr_invalid }; //~ ERROR is not a valid pointer
}

0 comments on commit 5063880

Please sign in to comment.