rust/src/test/ui/consts/const-eval/ub-upvars.rs

13 lines
372 B
Rust
Raw Normal View History

#![feature(const_transmute)]
#![allow(const_err)] // make sure we cannot allow away the errors tested here
use std::mem;
2018-10-01 05:52:47 -05:00
const BAD_UPVAR: &FnOnce() = &{ //~ ERROR it is undefined behavior to use this value
let bad_ref: &'static u16 = unsafe { mem::transmute(0usize) };
let another_var = 13;
move || { let _ = bad_ref; let _ = another_var; }
};
fn main() {}