Skip to content

Commit e574470

Browse files
committed
Duplicate compile-fail tests for intptrcast
1 parent fd3a291 commit e574470

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// Validation makes this fail in the wrong place
2+
// compile-flags: -Zmiri-disable-validation -Zmiri-seed=0000000000000000
3+
4+
fn main() {
5+
let g = unsafe {
6+
std::mem::transmute::<usize, fn(i32)>(42)
7+
};
8+
9+
g(42) //~ ERROR dangling pointer was dereferenced
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// compile-flags: -Zmiri-seed=0000000000000000
2+
3+
fn main() {
4+
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR invalid use of NULL pointer
5+
panic!("this should never print: {}", x);
6+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// compile-flags: -Zmiri-seed=0000000000000000
2+
3+
fn main() {
4+
let p = 44 as *const i32;
5+
let x = unsafe { *p }; //~ ERROR dangling pointer was dereferenced
6+
panic!("this should never print: {}", x);
7+
}

0 commit comments

Comments
 (0)