]> git.lizzy.rs Git - rust.git/blob - src/tools/miri/tests/fail/dangling_pointers/deref-partially-dangling.rs
Auto merge of #98840 - cjgillot:span-inline-ctxt, r=wesleywiser
[rust.git] / src / tools / miri / tests / fail / dangling_pointers / 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 to 12 bytes starting at offset 0 is out-of-bounds
7     assert_eq!(val, 13);
8 }