Files
rust/tests/ui/consts/const-eval/heap/make-global-dangling.rs
T
Deadbeef fd48b7b8dd Comment more code and make tests clearer
Co-Authored-By: Ralf Jung <post@ralfj.de>
2025-07-16 00:50:20 +08:00

19 lines
459 B
Rust

// Ensure that we can't call `const_make_global` on dangling pointers.
#![feature(core_intrinsics)]
#![feature(const_heap)]
use std::intrinsics;
const Y: &u32 = unsafe {
&*(intrinsics::const_make_global(std::ptr::null_mut()) as *const u32)
//~^ error: pointer not dereferenceable
};
const Z: &u32 = unsafe {
&*(intrinsics::const_make_global(std::ptr::dangling_mut()) as *const u32)
//~^ error: pointer not dereferenceable
};
fn main() {}