rust-lang / rust-lang/rustc_codegen_gcc
Another UB found using rustlantis
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 has a different result under GCC debug and GCC release.
2 1 //debug
2 -1 // release
fn dump_var(var2: usize, val2: usize, var3: usize) {
println!("val2:{val2}")
}
#[inline(never)]
fn dump_var2(var2: usize, val2: usize, var3: usize) {
println!("val2:{val2}")
}
fn fn6(arg: bool, arg2: usize) -> bool {
dump_var(0, arg2, 0);
dump_var2(0, !arg as usize, 0);
true
}
fn main() {
let mut _1 = false;
let mut _3 = 2;
let mut _4 = (&1, 1);
loop {
if _4.1 == 0 {
if _4.1 == 1 {
_1 = true;
} else {
_1 = false;
}
} else if fn6(_1, _3) {
loop {
_3 = _4.1;
let mut _6 = 0;
_6 = 0;
let tmp2 = _6;
if tmp2 == 1 {
_4.0 = &_4.1
} else if tmp2 == 0 {
return;
} else {
break;
}
}
}
}
}
It looks like the cast of val as i128 is nonsensical. Since val is a boolean value, one would expect it to be either 1 or 0, and not -1.
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 by compiling and running the supplied Rust reproducer with GCC in debug and release modes, then trace the boolean-to-integer cast mentioned in the report. The issue is resolved when the cast consistently produces the expected boolean values rather than differing between builds.
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
- 35/100