File tree Expand file tree Collapse file tree 2 files changed +12
-6
lines changed
src/tools/miri/tests/fail/validity Expand file tree Collapse file tree 2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 33
44#[ derive( Copy , Clone ) ]
55#[ allow( unused) ]
6- enum E { A , B , C }
6+ enum E {
7+ A ,
8+ B ,
9+ C ,
10+ }
711
8- fn cast ( ptr : * const E ) { unsafe {
9- let _val = * ptr as u32 ; //~ERROR: enum value has invalid tag
10- } }
12+ fn cast ( ptr : * const E ) {
13+ unsafe {
14+ let _val = * ptr as u32 ; //~ERROR: enum value has invalid tag
15+ }
16+ }
1117
1218pub fn main ( ) {
1319 let v = u32:: MAX ;
Original file line number Diff line number Diff line change 11error: Undefined Behavior: enum value has invalid tag: 0xff
22 --> $DIR/invalid_enum_cast.rs:LL:CC
33 |
4- LL | let _val = *ptr as u32;
5- | ^^^^^^^^^^^ enum value has invalid tag: 0xff
4+ LL | let _val = *ptr as u32;
5+ | ^^^^^^^^^^^ enum value has invalid tag: 0xff
66 |
77 = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
88 = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
You can’t perform that action at this time.
0 commit comments