File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( i128_type) ]
2
+
3
+ fn main ( ) {
4
+ #[ cfg( target_pointer_width="64" ) ]
5
+ let bad = unsafe {
6
+ std:: mem:: transmute :: < & [ u8 ] , u128 > ( & [ 1u8 ] )
7
+ } ;
8
+ #[ cfg( target_pointer_width="32" ) ]
9
+ let bad = unsafe {
10
+ std:: mem:: transmute :: < & [ u8 ] , u64 > ( & [ 1u8 ] )
11
+ } ;
12
+ bad + 1 ; //~ ERROR a raw memory access tried to access part of a pointer value as raw bytes
13
+ }
Original file line number Diff line number Diff line change
1
+ #![ feature( i128_type) ]
2
+
3
+ fn main ( ) {
4
+ #[ cfg( target_pointer_width="64" ) ]
5
+ let bad = unsafe {
6
+ std:: mem:: transmute :: < u128 , & [ u8 ] > ( 42 )
7
+ } ;
8
+ #[ cfg( target_pointer_width="32" ) ]
9
+ let bad = unsafe {
10
+ std:: mem:: transmute :: < u64 , & [ u8 ] > ( 42 )
11
+ } ;
12
+ bad[ 0 ] ; //~ ERROR index out of bounds: the len is 0 but the index is 0
13
+ }
You can’t perform that action at this time.
0 commit comments