Skip to content

Commit b97aec7

Browse files
committed
Add failing test for NULL pointer
1 parent 13279f9 commit b97aec7

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// compile-flags: -Zmiri-permissive-provenance
2+
#![feature(strict_provenance)]
3+
4+
use std::ptr;
5+
6+
fn main() {
7+
let x = 5;
8+
let x_ptr = &x as *const i32;
9+
let x_usize = x_ptr.expose_addr();
10+
11+
unsafe {
12+
let _a = *ptr::from_exposed_addr::<i32>(0).with_addr(x_usize); //~ ERROR attempting a read access using
13+
}
14+
}

0 commit comments

Comments
 (0)