Closed
Description
I tried this code:
#[inline(never)]
fn unfilter(current: &mut [u8]) {
current.iter_mut().reduce(|&mut prev, curr| {
*curr = curr.wrapping_add(prev);
curr
});
}
fn main() {
let mut data = [255, 0, 18, 243, 13, 240, 255, 0, 4];
unfilter(&mut data);
assert_eq!(data, [255, 255, 17, 4, 17, 1, 0, 0, 4]);
}
And compiled with these arguments:
RUSTFLAGS="-Zsanitizer=address -Clink-dead-code -C codegen-units=1" cargo +nightly run -Z build-std --target=x86_64-unknown-linux-gnu --release
I expected to see this happen: assertion passes like it does on the playground or with cargo run
.
Instead, this happened:
thread 'main' panicked at src/main.rs:12:5:
assertion `left == right` failed
left: [255, 255, 18, 5, 0, 253, 239, 255, 4]
right: [255, 255, 17, 4, 17, 1, 0, 0, 4]
Meta
rustc +nightly --version --verbose
:
rustc 1.77.0-nightly (d5fd09972 2024-01-22)
binary: rustc
commit-hash: d5fd0997291ca0135401a39dff25c8a9c13b8961
commit-date: 2024-01-22
host: x86_64-unknown-linux-gnu
release: 1.77.0-nightly
LLVM version: 17.0.6
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Sanitizers for correctness and code qualityCategory: This is a bug.Issue: 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.Issue expected to be fixed by the next major LLVM upgrade, or backported fixes
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
nikic commentedon Jan 23, 2024
Also reproduces without
-Z build-std
. I also tested this with+b10e3758cdf73aa9155f6b955843731a66488b9c
, so it doesn't look like this issue has been fixed in LLVM 18.nikic commentedon Jan 23, 2024
opt-bisect points to:
IR for this function without and with LoopVectorize: https://gist.github.com/nikic/619764c58f3cd184326ffdd6831abc2e
nikic commentedon Jan 23, 2024
Upstream issue: llvm/llvm-project#79137
apiraino commentedon Jan 23, 2024
WG-prioritization assigning priority (Zulip discussion).
@rustbot label -I-prioritize +P-high
6 remaining items