Closed
Description
This program
#![allow(const_err)]
union Foo {
a: &'static u8,
b: usize,
}
const BAD: usize = unsafe { Foo { a: &1 }.b * 2};
fn main() {
let f = BAD;
}
leads to the following errors:
error[E0080]: referenced constant has errors
--> src/main.rs:10:13
|
8 | const BAD: usize = unsafe { Foo { a: &1 }.b * 2};
| ------------------- "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
9 | fn main() {
10 | let f = BAD;
| ^^^
error[E0080]: could not evaluate constant
--> src/main.rs:10:13
|
10 | let f = BAD;
| ^^^ referenced constant has errors
error[E0080]: constant evaluation error
--> src/main.rs:8:1
|
8 | const BAD: usize = unsafe { Foo { a: &1 }.b * 2};
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------^^
| |
| "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
error: aborting due to 3 previous errors
Seems like overkill to say three times that the constant has errors. ;)
Cc @oli-obk