make sure raw ptrs only have to be valid as far as they are used

This commit is contained in:
Ralf Jung 2018-10-22 18:34:48 +02:00
parent 26bb4f79dc
commit 44b3c38b44

View 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 };
}