Test that &* of a dangling (and even unaligned) ptr is okay
This commit is contained in:
parent
03ca15e62d
commit
e5cc8aaf5b
1 changed files with 7 additions and 0 deletions
7
tests/run-pass/ref-invalid-ptr.rs
Normal file
7
tests/run-pass/ref-invalid-ptr.rs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
fn main() {
|
||||
let x = 2usize as *const u32;
|
||||
let _y = unsafe { &*x as *const u32 };
|
||||
|
||||
let x = 0usize as *const u32;
|
||||
let _y = unsafe { &*x as *const u32 };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue