add test for validation finding use-after-free
This commit is contained in:
parent
e6e8773272
commit
77cc0cddd9
10
tests/compile-fail/validity/dangling_ref3.rs
Normal file
10
tests/compile-fail/validity/dangling_ref3.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
use std::mem;
|
||||||
|
|
||||||
|
fn dangling() -> *const u8 {
|
||||||
|
let x = 0u8;
|
||||||
|
&x as *const _
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _x: &i32 = unsafe { mem::transmute(dangling()) }; //~ ERROR dangling reference (use-after-free)
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user