mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-29 12:36:35 +03:00
fd48b7b8dd
Co-Authored-By: Ralf Jung <post@ralfj.de>
19 lines
459 B
Rust
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() {}
|