Add tests for -Zmiri-check-number-validity
This commit is contained in:
parent
1659ef4206
commit
b3be6b44b6
8
tests/compile-fail/uninit_float.rs
Normal file
8
tests/compile-fail/uninit_float.rs
Normal file
@ -0,0 +1,8 @@
|
||||
// compile-flags: -Zmiri-check-number-validity
|
||||
|
||||
// This test is adapted from https://github.com/rust-lang/miri/issues/1340#issue-600900312.
|
||||
|
||||
fn main() {
|
||||
let _val = unsafe { std::mem::MaybeUninit::<f32>::uninit().assume_init() };
|
||||
//~^ ERROR type validation failed at .value: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
|
||||
}
|
8
tests/compile-fail/uninit_integer.rs
Normal file
8
tests/compile-fail/uninit_integer.rs
Normal file
@ -0,0 +1,8 @@
|
||||
// compile-flags: -Zmiri-check-number-validity
|
||||
|
||||
// This test is from https://github.com/rust-lang/miri/issues/1340#issue-600900312.
|
||||
|
||||
fn main() {
|
||||
let _val = unsafe { std::mem::MaybeUninit::<usize>::uninit().assume_init() };
|
||||
//~^ ERROR type validation failed at .value: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
|
||||
}
|
8
tests/compile-fail/uninit_integer_signed.rs
Normal file
8
tests/compile-fail/uninit_integer_signed.rs
Normal file
@ -0,0 +1,8 @@
|
||||
// compile-flags: -Zmiri-check-number-validity
|
||||
|
||||
// This test is adapted from https://github.com/rust-lang/miri/issues/1340#issue-600900312.
|
||||
|
||||
fn main() {
|
||||
let _val = unsafe { std::mem::MaybeUninit::<i32>::uninit().assume_init() };
|
||||
//~^ ERROR type validation failed at .value: encountered uninitialized bytes, but expected initialized plain (non-pointer) bytes
|
||||
}
|
8
tests/run-pass/uninit_number_ignored.rs
Normal file
8
tests/run-pass/uninit_number_ignored.rs
Normal file
@ -0,0 +1,8 @@
|
||||
// This test is adapted from https://github.com/rust-lang/miri/issues/1340#issue-600900312.
|
||||
// This test passes because -Zmiri-check-number-validity is not passed.
|
||||
|
||||
fn main() {
|
||||
let _val1 = unsafe { std::mem::MaybeUninit::<usize>::uninit().assume_init() };
|
||||
let _val2 = unsafe { std::mem::MaybeUninit::<i32>::uninit().assume_init() };
|
||||
let _val3 = unsafe { std::mem::MaybeUninit::<f32>::uninit().assume_init() };
|
||||
}
|
Loading…
Reference in New Issue
Block a user