File tree Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Expand file tree Collapse file tree 3 files changed +30
-1
lines changed Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ pub const MIRI_DEFAULT_ARGS: &[&str] = &[
169169 "-Zalways-encode-mir" ,
170170 "-Zextra-const-ub-checks" ,
171171 "-Zmir-emit-retag" ,
172- "-Zmir-keep-place-mention " ,
172+ "-Zmir-preserve-ub " ,
173173 "-Zmir-opt-level=0" ,
174174 "-Zmir-enable-passes=-CheckAlignment,-CheckNull" ,
175175 // Deduplicating diagnostics means we miss events when tracking what happens during an
Original file line number Diff line number Diff line change 1+ // Ensure that we don't optimize out `SwitchInt` reads even if that terminator
2+ // branches to the same basic block on every target, since the operand may have
3+ // side-effects that affect analysis of the MIR.
4+ //
5+ // See <https://github.com/rust-lang/miri/issues/4237>.
6+
7+ use std:: mem:: MaybeUninit ;
8+
9+ fn main ( ) {
10+ let uninit: MaybeUninit < i32 > = MaybeUninit :: uninit ( ) ;
11+ let bad_ref: & i32 = unsafe { uninit. assume_init_ref ( ) } ;
12+ let & ( 0 | _) = bad_ref;
13+ //~^ ERROR: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
14+ }
Original file line number Diff line number Diff line change 1+ error: Undefined Behavior: using uninitialized data, but this operation requires initialized memory
2+ --> tests/fail/read_from_trivial_switch.rs:LL:CC
3+ |
4+ LL | let &(0 | _) = bad_ref;
5+ | ^^^^^^^^ using uninitialized data, but this operation requires initialized memory
6+ |
7+ = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
8+ = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
9+ = note: BACKTRACE:
10+ = note: inside `main` at tests/fail/read_from_trivial_switch.rs:LL:CC
11+
12+ note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace
13+
14+ error: aborting due to 1 previous error
15+
You can’t perform that action at this time.
0 commit comments