about summary refs log tree commit diff
path: root/tests/ui/consts/const-eval/heap/make-global-dangling.rs
blob: f4c5929bc416dcc94a5e01fda78e79f7aecd8d0a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// 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() {}