This commit is contained in:
The Miri Cronjob Bot 2024-06-13 05:13:16 +00:00 committed by Ralf Jung
parent 6771dc44b5
commit a49c65976c
2 changed files with 12 additions and 6 deletions

View File

@ -3,11 +3,17 @@
#[derive(Copy, Clone)]
#[allow(unused)]
enum E {A, B, C }
enum E {
A,
B,
C,
}
fn cast(ptr: *const E) { unsafe {
let _val = *ptr as u32; //~ERROR: enum value has invalid tag
}}
fn cast(ptr: *const E) {
unsafe {
let _val = *ptr as u32; //~ERROR: enum value has invalid tag
}
}
pub fn main() {
let v = u32::MAX;

View File

@ -1,8 +1,8 @@
error: Undefined Behavior: enum value has invalid tag: 0xff
--> $DIR/invalid_enum_cast.rs:LL:CC
|
LL | let _val = *ptr as u32;
| ^^^^^^^^^^^ enum value has invalid tag: 0xff
LL | let _val = *ptr as u32;
| ^^^^^^^^^^^ enum value has invalid tag: 0xff
|
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
= help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information