make sure raw ptrs only have to be valid as far as they are used
This commit is contained in:
parent
26bb4f79dc
commit
44b3c38b44
1 changed files with 9 additions and 0 deletions
9
tests/run-pass/deref_partially_dangling_raw.rs
Normal file
9
tests/run-pass/deref_partially_dangling_raw.rs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
// Deref a raw ptr to access a field of a large struct, where the field
|
||||
// is allocated but not the entire struct is.
|
||||
// For now, we want to allow this.
|
||||
|
||||
fn main() {
|
||||
let x = (1, 1);
|
||||
let xptr = &x as *const _ as *const (i32, i32, i32);
|
||||
let _val = unsafe { (*xptr).1 };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue