]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/deallocate-twice.rs
Merge pull request #237 from RalfJung/reallocate
[rust.git] / tests / compile-fail / deallocate-twice.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: tried to deallocate with a pointer not to the beginning of an existing object
9
10 use alloc::heap::*;
11 fn main() {
12     unsafe {
13         let x = Heap.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
14         Heap.dealloc(x, Layout::from_size_align_unchecked(1, 1));
15         Heap.dealloc(x, Layout::from_size_align_unchecked(1, 1));
16     }
17 }