Skip to content

Commit

Permalink
Add regression test for SimplifyBranchSame miscompilation
Browse files Browse the repository at this point in the history
  • Loading branch information
tmiasko committed Oct 4, 2020
1 parent 80d5017 commit f271957
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/ui/mir/simplify-branch-same.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Regression test for SimplifyBranchSame miscompilation.
// run-pass

macro_rules! m {
($a:expr, $b:expr, $c:block) => {
match $a {
Lto::Fat | Lto::Thin => { $b; (); $c }
Lto::No => { $b; () }
}
}
}

pub enum Lto { No, Thin, Fat }

fn f(mut cookie: u32, lto: Lto) -> u32 {
let mut _a = false;
m!(lto, _a = true, {cookie = 0});
cookie
}

fn main() { assert_eq!(f(42, Lto::Thin), 0) }

0 comments on commit f271957

Please sign in to comment.