]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/reallocate-change-alloc.rs
Auto merge of #1151 - divergentdave:statx-AT_EMPTY_PATH, r=RalfJung
[rust.git] / tests / compile-fail / reallocate-change-alloc.rs
1 #![feature(allocator_api)]
2
3 extern crate alloc;
4
5 use alloc::alloc::Global;
6 use std::alloc::{AllocRef, Layout};
7
8 fn main() {
9     unsafe {
10         let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
11         Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1).unwrap();
12         let _z = *(x.as_ptr() as *mut u8); //~ ERROR dangling pointer was dereferenced
13     }
14 }