Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MatchBranchSimplication (a disabled mir-opt) is unsound #78239

Closed
pnkfelix opened this issue Oct 22, 2020 · 1 comment · Fixed by #78191
Closed

MatchBranchSimplication (a disabled mir-opt) is unsound #78239

pnkfelix opened this issue Oct 22, 2020 · 1 comment · Fixed by #78191
Labels
A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@pnkfelix
Copy link
Member

Spawned off of PR #78151, which turned the mir-opt MatchBranchSimplification off by default.

I just want a dedicated issue for discussing the unsoundness identified there, and to track how resolve this bug in the mir-opt (and then maybe turn it back on again, if it can pay for its own cost, which it might not have done before...)

@pnkfelix pnkfelix added the C-bug Category: This is a bug. label Oct 22, 2020
@pnkfelix pnkfelix changed the title MatchBranchSimplication is unsound MatchBranchSimplication (a disabled mir-opt) is unsound Oct 22, 2020
@pnkfelix pnkfelix added the A-mir-opt Area: MIR optimizations label Oct 22, 2020
@camelid camelid added the I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness label Oct 22, 2020
@rustbot rustbot added the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 22, 2020
@camelid camelid removed the I-prioritize Issue: Indicates that prioritization has been requested for this issue. label Oct 22, 2020
@JohnTitor JohnTitor added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Oct 22, 2020
@bors bors closed this as completed in 597b4c5 Oct 25, 2020
@tmiasko
Copy link
Contributor

tmiasko commented Nov 3, 2020

For the record, an example code that was being miscompiled:

fn main() {
    let a = &mut true;
    let b;
    match  *a {
        true => {
            *a = false;
            b = true;
            ()
        }
        _ => {
            *a = false;
            b = false;
            ()
        }
    };
    assert!(b);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations C-bug Category: This is a bug. I-unsound Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants