Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5063880

Browse files
committed
Auto merge of rust-lang#2153 - RalfJung:ptr-invalid, r=RalfJung
with permissive-provenance set, we already treat ptr::invalid correctly (same for strict provenance, but there it is not surprising)
2 parents 22c97b3 + fcf3bc2 commit 5063880

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// compile-flags: -Zmiri-permissive-provenance
2+
#![feature(strict_provenance)]
3+
4+
// Ensure that a `ptr::invalid` ptr is truly invalid.
5+
fn main() {
6+
let x = 42;
7+
let xptr = &x as *const i32;
8+
let xptr_invalid = std::ptr::invalid::<i32>(xptr.expose_addr());
9+
let _val = unsafe { *xptr_invalid }; //~ ERROR is not a valid pointer
10+
}

0 commit comments

Comments
 (0)