Duplicate compile-fail tests for intptrcast
This commit is contained in:
parent
fd3a291db4
commit
e57447014d
3 changed files with 23 additions and 0 deletions
10
tests/compile-fail/intptrcast_cast_int_to_fn_ptr.rs
Normal file
10
tests/compile-fail/intptrcast_cast_int_to_fn_ptr.rs
Normal 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
|
||||
}
|
||||
6
tests/compile-fail/intptrcast_null_pointer_deref.rs
Normal file
6
tests/compile-fail/intptrcast_null_pointer_deref.rs
Normal 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);
|
||||
}
|
||||
7
tests/compile-fail/intptrcast_wild_pointer_deref.rs
Normal file
7
tests/compile-fail/intptrcast_wild_pointer_deref.rs
Normal 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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue