]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/reallocate-dangling.rs
the test suite assumes a libstd with full MIR; run test suite on xargo-built foreign...
[rust.git] / tests / compile-fail / reallocate-dangling.rs
1 #![feature(alloc, allocator_api)]
2
3 extern crate alloc;
4
5 use alloc::alloc::Global;
6 use std::alloc::*;
7
8 // error-pattern: dangling pointer was dereferenced
9
10 fn main() {
11     unsafe {
12         let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
13         Global.dealloc(x, Layout::from_size_align_unchecked(1, 1));
14         Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1).unwrap();
15     }
16 }