wild pointer and null pointer deref

This commit is contained in:
Oliver Schneider 2016-04-22 15:00:19 +02:00 committed by Oliver 'ker' Schneider
parent ef5fc75c35
commit feca81307f

View file

@ -46,4 +46,15 @@ fn dangling_pointer_deref() -> i32 {
unsafe { *p } //~ ERROR: dangling pointer was dereferenced
}
#[miri_run]
fn wild_pointer_deref() -> i32 {
let p = 42 as *const i32;
unsafe { *p } //~ ERROR: attempted to interpret some raw bytes as a pointer address
}
#[miri_run]
fn null_pointer_deref() -> i32 {
unsafe { *std::ptr::null() } //~ ERROR: attempted to interpret some raw bytes as a pointer address
}
fn main() {}