rust-lang / rust-lang/rustc_codegen_gcc
Operation resulting in a NaN gets optimized away, changing the result to infinity.
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 105
- Avg merge
- 8h 20m
- Merged PRs (30d)
- 14
Description
This is, once again, an ARM-specific bug.
When this code is compiled with LLVM(or release GCC on x86_64, or debug GCC on ARM), it prints NaN.
When the same code is compiled with release GCC on ARM, it produces an infinity value instead.
#[no_mangle]
#[inline(never)]
fn dump_var(val3: f32) {
println!("{val3:?}")
}
fn fn2(param: f32) {
let inf = param * 170141170000000000000000000000000000000.0;
let should_be_nan = inf + 0.0 - inf;
dump_var(should_be_nan);
}
fn main() {
fn2(3.0);
}
Subtracting infinity from ininifty ought to result in an NaN value.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided Rust reproducer, especially fn2 and the inf + 0.0 - inf expression, and compare release GCC output on ARM with LLVM and x86_64 or debug GCC. Trace the generated operation and verify that the compiled program preserves the expected NaN result rather than producing infinity.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100