]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/reallocate-change-alloc.rs
297029676962bd702ce058a0a3defa46c304068b
[rust.git] / tests / compile-fail / reallocate-change-alloc.rs
1 use std::alloc::{alloc, realloc, Layout};
2
3 fn main() {
4     unsafe {
5         let x = alloc(Layout::from_size_align_unchecked(1, 1));
6         realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
7         let _z = *x; //~ ERROR dereferenced after this allocation got freed
8     }
9 }