rust/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

23 lines
524 B
Rust
Raw Normal View History

2021-12-25 07:35:11 -06:00
#![feature(core_intrinsics)]
#![feature(const_heap)]
#![feature(const_mut_refs)]
use std::intrinsics;
const _X: &'static u8 = unsafe {
let ptr = intrinsics::const_allocate(4, 4);
intrinsics::const_deallocate(ptr, 4, 4);
&*ptr
//~^ error: evaluation of constant value failed
};
const _Y: u8 = unsafe {
let ptr = intrinsics::const_allocate(4, 4);
let reference = &*ptr;
intrinsics::const_deallocate(ptr, 4, 4);
*reference
//~^ error: evaluation of constant value failed
};
fn main() {}