File tree 2 files changed +29
-0
lines changed
src/test/ui/consts/const-eval
2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( const_transmute, const_raw_ptr_deref) ]
2
+
3
+ use std:: { mem, usize} ;
4
+
5
+ // Make sure we error with the right kind of error on a too large slice.
6
+ const TEST : ( ) = { unsafe { //~ NOTE
7
+ let slice: * const [ u8 ] = mem:: transmute ( ( 1usize , usize:: MAX ) ) ;
8
+ let _val = & * slice; //~ ERROR: any use of this value will cause an error
9
+ //~^ NOTE: total size is bigger than largest supported object
10
+ //~^^ on by default
11
+ } } ;
12
+
13
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error: any use of this value will cause an error
2
+ --> $DIR/dangling.rs:8:16
3
+ |
4
+ LL | / const TEST: () = { unsafe {
5
+ LL | | let slice: *const [u8] = mem::transmute((1usize, usize::MAX));
6
+ LL | | let _val = &*slice;
7
+ | | ^^^^^^^ invalid slice: total size is bigger than largest supported object
8
+ LL | |
9
+ LL | |
10
+ LL | | } };
11
+ | |____-
12
+ |
13
+ = note: `#[deny(const_err)]` on by default
14
+
15
+ error: aborting due to previous error
16
+
You can’t perform that action at this time.
0 commit comments