Open
Description
I tried this code (test case taken from this comment):
fn main() {
let (a, b, c) = std::hint::black_box((-1.9369631e13f32, 2.1513551e-7, -1.7354427e-24));
dbg!(a.mul_add(b, c));
}
I expected to see this happen: The correct result should be printed as mul_add
is guaranteed to return the correctly rounded result, which is -4167095.8.
Instead, this happened: On both i686-pc-windows-gnu
and x86_64-pc-windows-gnu
, -4167095.5 is printed instead. This is due to the FMA implementation in MinGW being incorrect (upstream bug report). This is unsound as LLVM is allowed to rely on FMA returning correct results when optimising.
Meta
rustc --version --verbose
:
rustc 1.88.0-nightly (74509131e 2025-04-29)
binary: rustc
commit-hash: 74509131e85a97353c67c503ea32e148a56cf4bd
commit-date: 2025-04-29
host: x86_64-unknown-linux-gnu
release: 1.88.0-nightly
LLVM version: 20.1.2
Metadata
Metadata
Assignees
Labels
Area: Floating point numbers and arithmeticCategory: This is a bug.Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessToolchain: GNU, Operating system: WindowsMedium priorityRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the library team, which will review and decide on the PR/issue.