Add test for #51559

Closes #51559
This commit is contained in:
Ilija Tovilo 2019-07-24 14:09:26 +02:00
parent a7f28678bb
commit f49a96501d
No known key found for this signature in database
GPG Key ID: 3F123D0ADD448198
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,7 @@
#![feature(const_raw_ptr_to_usize_cast)]
const BAR: *mut () = ((|| 3) as fn() -> i32) as *mut ();
pub const FOO: usize = unsafe { BAR as usize };
//~^ ERROR it is undefined behavior to use this value
fn main() {}

View File

@ -0,0 +1,11 @@
error[E0080]: it is undefined behavior to use this value
--> $DIR/issue-51559.rs:4:1
|
LL | pub const FOO: usize = unsafe { BAR as usize };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ type validation failed: encountered a pointer, but expected initialized plain (non-pointer) bytes
|
= note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rust compiler repository if you believe it should not be considered undefined behavior
error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.