-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-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 codeI-prioritizeIssue: Indicates that prioritization has been requested for this issue.Issue: Indicates that prioritization has been requested for this issue.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
I would expect the following program to always terminate since the address of a
must be distinct from the address of b
. Instead, it never terminates when built with -O
:
fn main() {
f([32; 4]);
}
#[inline(never)]
pub fn f(a: [usize; 4]) {
g(a, a)
}
#[inline(never)]
pub fn g(mut a: [usize; 4], mut b: [usize; 4]) {
a[0] = 0;
b[0] = 1;
assert!(a[0] != b[0]);
h(a.as_ptr(), b.as_ptr());
}
#[inline(never)]
pub fn h(x: *const usize, y: *const usize) {
while x == y {}
}
$ rustc +b41634205b549a62cfa55363d1e00c4143d30033 a.rs && ./a
$ rustc +b41634205b549a62cfa55363d1e00c4143d30033 a.rs -O && ./a
^C
Meta
rustc +b41634205b549a62cfa55363d1e00c4143d30033--version --verbose
:
rustc 1.91.0-nightly (b41634205 2025-08-28)
binary: rustc
commit-hash: b41634205b549a62cfa55363d1e00c4143d30033
commit-date: 2025-08-28
host: x86_64-unknown-linux-gnu
release: 1.91.0-nightly
LLVM version: 21.1.0
sylv256
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-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 codeI-prioritizeIssue: Indicates that prioritization has been requested for this issue.Issue: Indicates that prioritization has been requested for this issue.S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueStatus: A Minimal Complete and Verifiable Example has been found for this issueT-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.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.