Repository navigation
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 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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Description
Compiler Explorer: https://godbolt.org/z/v6aeMarE7
small.rs
#[inline(never)]
fn f(buf: &[u8], x: u64) -> (u64, usize) {
let mut at = 1;
let mut acc = 0u64;
loop {
acc ^= x;
let more = at < buf.len();
at += more as usize;
if !more {
break;
}
}
(acc, buf[at..].len())
}
fn main() {
let buf = vec![0u8; std::hint::black_box(4)];
println!("{:?}", f(&buf, 1));
}Reproduce:
Correct:
$ rustc small.rs && ./small
(0, 0)
Miscompile:
$ rustc -O small.rs && ./small
thread 'main' (4184111) panicked at small.rs:13:14:
range start index 5 out of range for slice of length 4
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Meta
rustc --version --verbose:
rustc 1.101.0-nightly (91e426a05 2026-10-13)
binary: rustc
commit-hash: 91e426a0518d5bb3672330c5238ccda6fd26fb54
commit-date: 2026-10-13
host: x86_64-unknown-linux-gnu
release: 1.101.0-nightly
LLVM version: 23.1.3
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 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.regression-from-stable-to-stablePerformance or correctness regression from one stable version to another.Performance or correctness regression from one stable version to another.
Activity
saethlin commentedon Oct 18, 2026
Bisects to #158734 (LLVM 23).
rustbot commentedon Oct 27, 2026
Assigning P-high (discussion on Zulip)
Should it be (or was it already?) reported upstream?
cc @rust-lang/wg-llvm (in case you were not notified by the
A-LLVMlabelling)