File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed 
src/tools/miri/tests/fail/uninit Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,10 @@ fn main() {
1818
1919        // Turns out the discriminant is (currently) stored 
2020        // in the 1st pointer, so the second half is padding. 
21-         let  c = ( & p as  * const  mem:: MaybeUninit < E > ) . byte_add ( mem:: size_of :: < & ' static  ( ) > ( ) )  as  * const  u8 ; 
21+         let  c = & p as  * const  _  as  * const  u8 ; 
22+         let  padding_offset = mem:: size_of :: < & ' static  ( ) > ( ) ; 
2223        // Read a padding byte. 
23-         let  _val = * c. add ( 0 ) ; 
24+         let  _val = * c. add ( padding_offset ) ; 
2425        //~^ERROR: uninitialized 
2526    } 
2627} 
Original file line number Diff line number Diff line change 11error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
22  --> tests/fail/uninit/padding-enum.rs:LL:CC
33   |
4- LL |         let _val = *c.add(0 );
5-    |                    ^^^^^^^^^ using uninitialized data, but this operation requires initialized memory
4+ LL |         let _val = *c.add(padding_offset );
5+    |                    ^^^^^^^^^^^^^^^^^^^^^^  using uninitialized data, but this operation requires initialized memory
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