Auto merge of #1333 - RalfJung:flag-test, r=RalfJung
Make sure we find many failures even with other checks disabled
This commit is contained in:
commit
4ed3d487a6
@ -1,3 +1,6 @@
|
||||
// Make sure we find these even with many checks disabled.
|
||||
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
|
||||
|
||||
fn main() {
|
||||
let p = {
|
||||
let b = Box::new(42);
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Make sure we find these even with many checks disabled.
|
||||
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
|
||||
|
||||
fn main() {
|
||||
let p = {
|
||||
let b = Box::new(42);
|
||||
|
@ -1,4 +1,4 @@
|
||||
// error-pattern: the evaluated program aborted execution: attempted to instantiate uninhabited type `!`
|
||||
// error-pattern: the evaluated program aborted execution: attempted to instantiate uninhabited type `!`
|
||||
#![feature(never_type)]
|
||||
|
||||
#[allow(deprecated, invalid_value)]
|
6
tests/compile-fail/intrinsics/zero_fn_ptr.rs
Normal file
6
tests/compile-fail/intrinsics/zero_fn_ptr.rs
Normal file
@ -0,0 +1,6 @@
|
||||
// error-pattern: the evaluated program aborted execution: attempted to zero-initialize type `fn()`, which is invalid
|
||||
|
||||
#[allow(deprecated, invalid_value)]
|
||||
fn main() {
|
||||
unsafe { std::mem::zeroed::<fn()>() };
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
// Validation makes this fail in the wrong place
|
||||
// compile-flags: -Zmiri-disable-validation
|
||||
// Make sure we find these even with many checks disabled.
|
||||
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
|
||||
|
||||
fn main() {
|
||||
let b = unsafe { std::mem::transmute::<u8, bool>(2) };
|
||||
|
@ -1,5 +1,6 @@
|
||||
// Validation makes this fail in the wrong place
|
||||
// compile-flags: -Zmiri-disable-validation
|
||||
// Make sure we find these even with many checks disabled.
|
||||
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
|
||||
|
||||
fn main() {
|
||||
assert!(std::char::from_u32(-1_i32 as u32).is_none());
|
||||
|
@ -1,5 +1,6 @@
|
||||
// Validation makes this fail in the wrong place
|
||||
// compile-flags: -Zmiri-disable-validation
|
||||
// Make sure we find these even with many checks disabled.
|
||||
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
|
||||
|
||||
// error-pattern: invalid enum discriminant
|
||||
|
||||
|
8
tests/compile-fail/invalid_int.rs
Normal file
8
tests/compile-fail/invalid_int.rs
Normal file
@ -0,0 +1,8 @@
|
||||
// Validation makes this fail in the wrong place
|
||||
// Make sure we find these even with many checks disabled.
|
||||
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
|
||||
|
||||
fn main() {
|
||||
let i = unsafe { std::mem::MaybeUninit::<i32>::uninit().assume_init() };
|
||||
let _x = i + 0; //~ ERROR this operation requires initialized memory
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
// error-pattern: the evaluated program aborted execution: attempted to zero-initialize type `fn()`, which is invalid
|
||||
|
||||
#[allow(deprecated, invalid_value)]
|
||||
fn main() {
|
||||
unsafe { std::mem::zeroed::<fn()>() };
|
||||
}
|
@ -1,3 +1,6 @@
|
||||
// Make sure we find these even with many checks disabled.
|
||||
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
|
||||
|
||||
fn main() {
|
||||
let mut p = &42;
|
||||
unsafe {
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Make sure we catch this even without validation
|
||||
// compile-flags: -Zmiri-disable-validation
|
||||
|
||||
// Make sure that we cannot load from memory a `&mut` that got already invalidated.
|
||||
fn main() {
|
||||
let x = &mut 42;
|
||||
|
@ -1,3 +1,6 @@
|
||||
// Make sure we catch this even without validation
|
||||
// compile-flags: -Zmiri-disable-validation
|
||||
|
||||
// Make sure that we cannot load from memory a `&` that got already invalidated.
|
||||
fn main() {
|
||||
let x = &mut 42;
|
||||
|
@ -1,5 +1,5 @@
|
||||
// This should fail even without validation
|
||||
// compile-flags: -Zmiri-disable-validation
|
||||
// This should fail even without validation or Stacked Borrows.
|
||||
// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
|
||||
|
||||
fn main() {
|
||||
let x = [2u16, 3, 4]; // Make it big enough so we don't get an out-of-bounds error.
|
||||
|
@ -1,5 +1,5 @@
|
||||
// This should fail even without validation.
|
||||
// compile-flags: -Zmiri-disable-validation
|
||||
// This should fail even without validation or Stacked Borrows.
|
||||
// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
|
||||
|
||||
fn main() {
|
||||
let x = [2u32, 3]; // Make it big enough so we don't get an out-of-bounds error.
|
||||
|
@ -1,5 +1,5 @@
|
||||
// This should fail even without validation.
|
||||
// compile-flags: -Zmiri-disable-validation
|
||||
// This should fail even without validation or Stacked Borrows.
|
||||
// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
|
||||
|
||||
fn main() {
|
||||
let x = [2u16, 3, 4, 5]; // Make it big enough so we don't get an out-of-bounds error.
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Make sure we catch this even without Stacked Borrows
|
||||
// compile-flags: -Zmiri-disable-stacked-borrows
|
||||
use std::mem;
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Make sure we catch this even without Stacked Borrows
|
||||
// compile-flags: -Zmiri-disable-stacked-borrows
|
||||
use std::mem;
|
||||
|
||||
fn main() {
|
||||
|
@ -1,3 +1,5 @@
|
||||
// Make sure we catch this even without Stacked Borrows
|
||||
// compile-flags: -Zmiri-disable-stacked-borrows
|
||||
use std::mem;
|
||||
|
||||
fn dangling() -> *const u8 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user