rust/tests/ui/consts/const-deref-ptr.rs
2025-04-08 23:06:31 +03:00

8 lines
251 B
Rust

// Check that you can't dereference invalid raw pointers in constants.
fn main() {
static C: u64 = unsafe {*(0xdeadbeef as *const u64)};
//~^ ERROR could not evaluate static initializer
//~| NOTE dangling pointer
println!("{}", C);
}