<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/69344>69344</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang++] crash when trying compile a multi-if-else code
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
jiacai-wang
</td>
</tr>
</table>
<pre>
### error message
./if.inc:26663:9: warning: stack nearly exhausted; compilation time may suffer, and crashes due to stack overflow are likely [-Wstack-exhausted]
printf("%d\n", 8888);
clang: error: unable to execute command: Segmentation fault
clang: error: clang frontend command failed due to signal (use -v to see invocation)
clang version 10.0.0-4ubuntu1
### how to reproduce:
multi-if-else.cpp
```
#include <ctime>
#include <iostream>
using namespace std;
int getVal() {
srand(time(0));
return rand();
}
int main() {
int val = getVal();
val = val % 10000;
if (val == -1) {
printf("%d\n", val);
}
#include "if.inc"
}
```
a 'gen.sh' script to generate if.inc
```
#!/bin/bash
for ((i=0; i<10000; i++))
do
echo -e " else if(val == $i) {"
echo -e " printf(\"%d\\\n\", $((i+1)));"
echo -e " }"
done
```
`clang++ multi-if-else.cpp` and it crashes.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8Vc2O4ygQfhpyKdnC-P-QQyfZvMBKu2eCyzYzGCJ-0tNvvwI7k6SneyOEHVe5vp8ywJ2Tk0bck_pA6tOOBz8bu_8hueAye-d62l3M8LEnrFwHoLXGwoLO8QkJPRH6ts45YWc55lILUr6xpmlKUr71pHyDd2611FO8dZ6Ln6CRW_UB-GvmwXkcSHkAYZarVNxLo8HLBWHhH-DCOKIl7AhcDyAsdzM6GAKCN1stc0M7KvMO3CIo-RPVB5D6kP2bwtkDoz6tPGH7Xa3UfiSsI4wRVg-kPup0e4Su6zrCelIe1leE4iv9JD7eBM0vKrHAXyiCx8h_4XqIwb9xWlD7VcvIg_LflUlPYLRGe4wC1xowcqlw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