summary refs log tree commit diff
path: root/src/tools/miri/tests/fail/alloc/reallocate-change-alloc.rs
blob: 3ad56da2c2fffcadb17acd51b4c4e492e019d072 (plain)
1
2
3
4
5
6
7
8
9
use std::alloc::{alloc, realloc, Layout};

fn main() {
    unsafe {
        let x = alloc(Layout::from_size_align_unchecked(1, 1));
        let _y = realloc(x, Layout::from_size_align_unchecked(1, 1), 1);
        let _z = *x; //~ ERROR: dereferenced after this allocation got freed
    }
}