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:
bors 2020-04-14 08:25:34 +00:00
commit 4ed3d487a6
18 changed files with 48 additions and 16 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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)]

View 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()>() };
}

View File

@ -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) };

View File

@ -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());

View File

@ -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

View 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
}

View File

@ -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()>() };
}

View File

@ -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 {

View File

@ -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;

View File

@ -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;

View File

@ -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.

View File

@ -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.

View File

@ -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.

View File

@ -1,3 +1,5 @@
// Make sure we catch this even without Stacked Borrows
// compile-flags: -Zmiri-disable-stacked-borrows
use std::mem;
fn main() {

View File

@ -1,3 +1,5 @@
// Make sure we catch this even without Stacked Borrows
// compile-flags: -Zmiri-disable-stacked-borrows
use std::mem;
fn main() {

View File

@ -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 {