rust/tests/compile-fail/reallocate-change-alloc.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

15 lines
392 B
Rust

#![feature(allocator_api)]
extern crate alloc;
use alloc::alloc::Global;
use std::alloc::{AllocRef, Layout};
fn main() {
unsafe {
let x = Global.alloc(Layout::from_size_align_unchecked(1, 1)).unwrap();
Global.realloc(x, Layout::from_size_align_unchecked(1, 1), 1).unwrap();
let _z = *(x.as_ptr() as *mut u8); //~ ERROR dangling pointer was dereferenced
}
}