Duplicate compile-fail tests for intptrcast

This commit is contained in:
Christian Poveda 2019-06-21 16:32:54 -05:00
parent fd3a291db4
commit e57447014d
3 changed files with 23 additions and 0 deletions

View file

@ -0,0 +1,10 @@
// Validation makes this fail in the wrong place
// compile-flags: -Zmiri-disable-validation -Zmiri-seed=0000000000000000
fn main() {
let g = unsafe {
std::mem::transmute::<usize, fn(i32)>(42)
};
g(42) //~ ERROR dangling pointer was dereferenced
}

View file

@ -0,0 +1,6 @@
// compile-flags: -Zmiri-seed=0000000000000000
fn main() {
let x: i32 = unsafe { *std::ptr::null() }; //~ ERROR invalid use of NULL pointer
panic!("this should never print: {}", x);
}

View file

@ -0,0 +1,7 @@
// compile-flags: -Zmiri-seed=0000000000000000
fn main() {
let p = 44 as *const i32;
let x = unsafe { *p }; //~ ERROR dangling pointer was dereferenced
panic!("this should never print: {}", x);
}