rust-lang / rust-lang/rustc_codegen_gcc
Casting infinity to an intiger sometimes results in a 0 value(with optimizations enabled)
Open
Nobody has claimed this yet.
bug
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 105
- Avg merge
- 8h 20m
- Merged PRs (30d)
- 14
Description
This program(which runs fine under MIRI) produces incorrect results when compiled with cg_gcc.
fn main() {
let _2 = [true, false, true, true, false];
let _1 = 0;
let mut _6 = 0.0;
let RET = 0.0;
let mut _3 = 51216f32;
let mut _4 = _3 * _3;
let _13 = 0;
let mut _14 = _4;
let _20 = &mut _14;
_4 = *_20 * *_20 * _4;
_6 = *_20;
*_20 = _4;
let mut _28 = 0.0;
let _41 = &mut _28;
*_41 = *_20;
let _39 = *_20 = *_41 * *_41;
let _12 = *_41 = -*_20;
_3 = *_41;
let _57 = *_41;
let _5 = *_41 = _3 * _6 * -_57;
let val = *_41;
let tmp = _28 * val;
let _78 = tmp as u128;
println!("{_78:?}");
}
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 Rust reproducer in the issue and run it under MIRI and cg_gcc with optimizations enabled, recording the differing output for the u128 cast. Trace the optimized code-generation path for the floating-point-to-integer conversion; done means cg_gcc no longer produces the incorrect zero result and agrees with MIRI.
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
- 45/100