]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/reallocate-dangling.rs
fix warnings in tests; update validation whitelist
[rust.git] / tests / compile-fail / reallocate-dangling.rs
1 #![feature(alloc, allocator_api)]
2
3 extern crate alloc;
4
5 use alloc::heap::Heap;
6 use alloc::allocator::*;
7
8 // error-pattern: dangling pointer was dereferenced
9
10 fn main() {
11     unsafe {
12         let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
13         Heap.dealloc(x, Layout::from_size_align_unchecked(1, 1));
14         Heap.realloc(x, Layout::from_size_align_unchecked(1, 1), Layout::from_size_align_unchecked(1, 1));
15     }
16 }