GCCRS gets killed (SIGKILL) when compiling function with massive if-else branches
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 2.9k
- Forks
- 231
- Avg merge
- 19h 55m
- Merged PRs (30d)
- 67
Description
Summary
When compiling a Rust function containing a large number of if-else branches (e.g., several thousand), GCCRS exceeds processing time and is terminated by SIGKILL, while Rustc compiles successfully with only a dead code warning.
Reproducer
I tried this code:
#![crate_type = "rlib"]
fn banana(v: &str) -> u32 {
if v == "1" { 1 }
else if v == "2" { 2 }
// ... Hundreds/Thousands of similar branches ...
else if v == "5205" { 5205 }
else { 5206 }
}
Does the code make use of any (1.49) nightly feature ?
- Nightly
Godbolt link
https://godbolt.org/z/Gsae38rae
Actual behavior
GCCRS fails to complete compilation (SIGKILL), indicating a severe performance bottleneck or infinite loop in the compiler.
Expected behavior
GCCRS should handle large but syntactically valid functions gracefully, possibly with a warning about code size or performance, but not crash.
GCC Version
14.0.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 reproducing the SIGKILL with the linked Godbolt example or the several-thousand-branch function, then compare GCCRS and rustc behavior. Trace the compiler stages processing the chained if-else expressions and identify where compilation time or memory grows unexpectedly. Done means the reproducer completes without being killed and existing compiler tests cover the regression.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, rust
- Domain
- compilers, performance
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100