Description
From #141038 (comment).
The following code with -Zmir-enable-passes=+GVN
triggers the assertion.
#![feature(custom_mir, core_intrinsics)]
use std::intrinsics::mir::*;
#[custom_mir(dialect = "runtime")]
pub fn repeat_place(mut idx1: usize, idx2: usize, val: &i32) -> i32 {
mir! {
let array;
let elem;
{
array = [*val; 5];
elem = &array[idx1];
idx1 = idx2;
RET = *elem;
Return()
}
}
}
fn main() {
assert_eq!(repeat_place(0, 5, &0), 0);
}
Metadata
Metadata
Assignees
Labels
Area: MIR optimizationsArea: MIR opt Global Value Numbering (GVN)A miscompilation found by RustlantisCategory: This is a bug.Issue: Correct Rust code lowers to incorrect machine codeIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessHigh priorityRelevant to the compiler team, which will review and decide on the PR/issue.