mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
add oversized-ref test back
This commit is contained in:
parent
28b0c87ad6
commit
1ac153f60b
@ -91,4 +91,12 @@ const VALID_ENUM2: Result<&'static [u8], ()> = { let e = Err(()); e };
|
||||
// Htting the (non-integer) array code in validation with an immediate local.
|
||||
const VALID_ARRAY: [Option<i32>; 0] = { let e = [None; 0]; e };
|
||||
|
||||
// Detecting oversized references.
|
||||
const OVERSIZED_REF: () = { unsafe {
|
||||
let slice: *const [u8] = transmute((1usize, usize::MAX));
|
||||
let _val = &*slice;
|
||||
//[with_flag]~^ ERROR: evaluation of constant value failed
|
||||
//[with_flag]~| slice is bigger than largest supported object
|
||||
} };
|
||||
|
||||
fn main() {}
|
||||
|
@ -52,6 +52,12 @@ LL | let _val = *(&mem as *const Align as *const [*const u8; 2]);
|
||||
= help: this code performed an operation that depends on the underlying bytes representing a pointer
|
||||
= help: the absolute address of a pointer is not known at compile-time, so such operations are not supported
|
||||
|
||||
error: aborting due to 7 previous errors
|
||||
error[E0080]: evaluation of constant value failed
|
||||
--> $DIR/detect-extra-ub.rs:97:16
|
||||
|
|
||||
LL | let _val = &*slice;
|
||||
| ^^^^^^^ constructing invalid value: encountered invalid reference metadata: slice is bigger than largest supported object
|
||||
|
||||
error: aborting due to 8 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0080`.
|
||||
|
Loading…
Reference in New Issue
Block a user