]> git.proxmox.com Git - rustc.git/blame - src/test/ui/const-ptr/out_of_bounds_read.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / src / test / ui / const-ptr / out_of_bounds_read.rs
CommitLineData
136023e0
XL
1// error-pattern: evaluation of constant value failed
2
3#![feature(const_ptr_read)]
136023e0
XL
4
5fn main() {
6 use std::ptr;
7
8 const DATA: [u32; 1] = [42];
9
10 const PAST_END_PTR: *const u32 = unsafe { DATA.as_ptr().add(1) };
11
12 const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) };
13 const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() };
14 const _MUT_READ: u32 = unsafe { (PAST_END_PTR as *mut u32).read() };
15}