]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/deref-partially-dangling.rs
a6d3aae414de003c15963b8454799adc39a9c786
[rust.git] / tests / compile-fail / deref-partially-dangling.rs
1 // Deref a raw ptr to access a field of a large struct, where the field
2 // is allocated but not the entire struct is.
3 fn main() {
4     let x = (1, 13);
5     let xptr = &x as *const _ as *const (i32, i32, i32);
6     let val = unsafe { (*xptr).1 }; //~ ERROR pointer must be in-bounds at offset 12, but is outside bounds of alloc
7     assert_eq!(val, 13);
8 }