-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
To catch at least one pattern that was miscompiled. The test is a minimization of the MCVE reported in <#132353>.
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//! The mir-opt added in <https://github.com/rust-lang/rust/pull/128299> unfortunately seems to lead | ||
//! to a miscompile (reported in <https://github.com/rust-lang/rust/issues/132353>, minimization | ||
//! reproduced in this test file). | ||
//@ revisions: release debug | ||
// Note: it's not strictly cargo's release profile, but any non-zero opt-level was sufficient to | ||
// reproduce the miscompile. | ||
//@[release] compile-flags: -C opt-level=1 | ||
//@[debug] compile-flags: -C opt-level=0 | ||
//@ run-pass | ||
|
||
fn pop_min(mut score2head: Vec<Option<usize>>) -> Option<usize> { | ||
loop { | ||
if let Some(col) = score2head[0] { | ||
score2head[0] = None; | ||
return Some(col); | ||
} | ||
} | ||
} | ||
|
||
fn main() { | ||
let min = pop_min(vec![Some(1)]); | ||
println!("min: {:?}", min); | ||
// panic happened on 1.83.0 beta in release mode but not debug mode. | ||
let _ = min.unwrap(); | ||
} |