rust/tests/compile-fail/deallocate-twice.rs
Tim Diekmann 3d8bf92a11
Rename Alloc to AllocRef
Required to land https://github.com/rust-lang/rust/pull/68529. Please see that PR for details. The CI is expected to fail until the PR is landed.
2020-01-29 04:10:33 +01:00

17 lines
417 B
Rust

#![feature(allocator_api)]
extern crate alloc;
use alloc::alloc::Global;
use std::alloc::{AllocRef, Layout};
// error-pattern: tried to deallocate dangling pointer
fn main() {
unsafe {
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Global.dealloc(x, Layout::from_size_align_unchecked(1, 1));
Global.dealloc(x, Layout::from_size_align_unchecked(1, 1));
}
}