Closed
Description
This code has differing behavior in debug and release (playground):
fn main() {
let black_box_zero = (std::env::args().len() - 1) as f32;
let result = 1.0 / ((-0.0) * black_box_zero);
let expected = f32::NEG_INFINITY;
assert_eq!(result, expected);
}
When compiled in debug mode (without optimizations), the program produces no output.
When compiled in release mode (with optimizations), the assertion fails:
thread 'main' panicked at 'assertion failed: `(left == right)`
left: `-inf`,
right: `-inf`', src/main.rs:5:5
(This output doesn't make sense to me: how can they be unequal, but both negative infinity?)
Metadata
Metadata
Assignees
Labels
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Floating point numbers and arithmeticCategory: 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.Performance or correctness regression from one stable version to another.