]> git.lizzy.rs Git - rust.git/blob - tests/compile-fail/deallocate-twice.rs
Auto merge of #1154 - TimDiekmann:rename-alloc, r=RalfJung
[rust.git] / tests / compile-fail / deallocate-twice.rs
1 #![feature(allocator_api)]
2
3 extern crate alloc;
4
5 use alloc::alloc::Global;
6 use std::alloc::{AllocRef, Layout};
7
8 // error-pattern: tried to deallocate dangling pointer
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.dealloc(x, Layout::from_size_align_unchecked(1, 1));
15     }
16 }