File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -91,4 +91,12 @@ const VALID_ENUM2: Result<&'static [u8], ()> = { let e = Err(()); e };
9191// Htting the (non-integer) array code in validation with an immediate local.
9292const VALID_ARRAY : [ Option < i32 > ; 0 ] = { let e = [ None ; 0 ] ; e } ;
9393
94+ // Detecting oversized references.
95+ const OVERSIZED_REF : ( ) = { unsafe {
96+ let slice: * const [ u8 ] = transmute ( ( 1usize , usize:: MAX ) ) ;
97+ let _val = & * slice;
98+ //[with_flag]~^ ERROR: evaluation of constant value failed
99+ //[with_flag]~| slice is bigger than largest supported object
100+ } } ;
101+
94102fn main ( ) { }
Original file line number Diff line number Diff line change @@ -52,6 +52,12 @@ LL | let _val = *(&mem as *const Align as *const [*const u8; 2]);
5252 = help: this code performed an operation that depends on the underlying bytes representing a pointer
5353 = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
5454
55- error: aborting due to 7 previous errors
55+ error[E0080]: evaluation of constant value failed
56+ --> $DIR/detect-extra-ub.rs:97:16
57+ |
58+ LL | let _val = &*slice;
59+ | ^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
60+
61+ error: aborting due to 8 previous errors
5662
5763For more information about this error, try `rustc --explain E0080`.
You can’t perform that action at this time.
0 commit comments