2019-07-27 04:03:12 -05:00
|
|
|
// Deref a raw ptr to access a field of a large struct, where the field
|
|
|
|
// is allocated but not the entire struct is.
|
|
|
|
fn main() {
|
|
|
|
let x = (1, 13);
|
|
|
|
let xptr = &x as *const _ as *const (i32, i32, i32);
|
2020-03-08 17:34:54 -05:00
|
|
|
let val = unsafe { (*xptr).1 }; //~ ERROR pointer must be in-bounds at offset 12, but is outside bounds of alloc
|
2019-07-27 04:03:12 -05:00
|
|
|
assert_eq!(val, 13);
|
|
|
|
}
|