File tree 2 files changed +12
-6
lines changed
src/tools/miri/tests/fail/validity
2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change 3
3
4
4
#[ derive( Copy , Clone ) ]
5
5
#[ allow( unused) ]
6
- enum E { A , B , C }
6
+ enum E {
7
+ A ,
8
+ B ,
9
+ C ,
10
+ }
7
11
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
+ }
11
17
12
18
pub fn main ( ) {
13
19
let v = u32:: MAX ;
Original file line number Diff line number Diff line change 1
1
error: Undefined Behavior: enum value has invalid tag: 0xff
2
2
--> $DIR/invalid_enum_cast.rs:LL:CC
3
3
|
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
6
6
|
7
7
= help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8
8
= 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