Repository navigation
SimplifyComparisonIntegral introduces access to a dead local variable #158231
Copy link
Copy link
Closed
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.I-miscompileIssue: Correct Rust code lowers to incorrect machine codeIssue: Correct Rust code lowers to incorrect machine codeP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Activity
- addedT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.C-bugCategory: This is a bug.Category: This is a bug.A-mir-optArea: MIR optimizationsArea: MIR optimizationsI-miscompileIssue: Correct Rust code lowers to incorrect machine codeIssue: Correct Rust code lowers to incorrect machine code
on Jun 21, 2026 - addedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingI-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}Issue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
on Jun 21, 2026 From what I can tell, the pass's logic for shuffling StorageDeads around tries to identify StorageDeads that would interfere with extending the lifetime of the comparison result, and sink them into successor blocks (i.e., after the
switchInt). In this case, the block is its own successor, so the StorageDead gets hoisted unintentionally. Presumably this problem can occur for any block involved in a loop.I think the
StorageLive(_2)in bb1 is also problematic, since StorageLive is defined to free the local and re-allocate it with. Probably the whole StorageLive/StorageDead handling needs to be overhauled completely.- removedneeds-triageThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triagingThis issue may need triage. Remove when done. See docs forge.rust-lang.org/release/issue-triaging
on Jun 22, 2026 @rustbot claim
- removedI-prioritizeIssue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}Issue needs a team member to assess the impact. Will be replaced by P-{low,medium,high,critical}
on Jul 19, 2026 Assigning P-high (discussion on Zulip).
- added 2 commits that reference this issue
on Jul 28, 2026 - added a commit that references this issue
on Jul 28, 2026
Metadata
Metadata
Assignees
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-bugCategory: This is a bug.Category: This is a bug.I-miscompileIssue: Correct Rust code lowers to incorrect machine codeIssue: Correct Rust code lowers to incorrect machine codeP-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
rustc a.rs --crate-type=lib -Zmir-opt-level=0 -Zmir-enable-passes=+SimplifyComparisonIntegral -Zunpretty=mirMeta
rustc --version --verbose: