rust/tests/ui/consts/const-eval/issue-49296.rs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

15 lines
283 B
Rust
Raw Normal View History

2018-10-28 23:09:32 -05:00
// issue-49296: Unsafe shenigans in constants can result in missing errors
use std::mem::transmute;
2018-10-28 23:09:32 -05:00
const fn wat(x: u64) -> &'static u64 {
unsafe { transmute(&x) }
}
2018-10-28 23:09:32 -05:00
const X: u64 = *wat(42);
2021-06-18 12:31:56 -05:00
//~^ ERROR evaluation of constant value failed
2018-10-28 23:09:32 -05:00
fn main() {
println!("{}", X);
}