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

fn main() {
    unsafe {
        let x = alloc(Layout::from_size_align_unchecked(1, 1));
        dealloc(x, Layout::from_size_align_unchecked(1, 1));
        let _z = realloc(x, Layout::from_size_align_unchecked(1, 1), 1); //~ERROR: has been freed
    }
}