<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/106239>106239</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Crash with O2 optimization flag
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cardigan1008
</td>
</tr>
</table>
<pre>
I compiled this code with -O2 flag and it crashed. The code is:
```c
#include <stdint.h>
long a, c;
unsigned d;
int32_t g;
uint8_t h[];
long b(long p1, long k) {
long e = k;
int b = 0;
while (e) {
e /= 10;
b++;
}
for (int f = 0; f < b; f++)
p1 *= 10;
a = p1 + k;
return a;
}
long i(int p1, int, int l) {
int j = l / p1;
for (int f = 0; f < p1; f++) {
if (d > l)
break;
c = d += j;
}
}
uint32_t m() {
for (g = 8; b(35, 46) - 3546 + g >= 0; g--)
;
h[i(g + 1, 0, -4294967221)];
}
```
The details can be found here: https://godbolt.org/z/37WsGxMcv
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE1vnDAQ_TXmMtoVjPk8cMjuhqqHKpdKPUbG9oITr1lhk7T59ZUNgc1WqoRgGM-8eW_kGWat6oyUNckOJDtFbHL9MNacjUJ1zCRxXEbtIP7U34EPl6vSUoDrlQU-CAnvyvWwe0I4a9YBMwKUAz4y20uxh5-9nMOUJfSBxCcSf77zeH748o9UGa4nIYHQo3VCGbfvCX2cj_VgOmAEj8AJPcy-yQTiAsTqUsZRfHbQbUHKuPLZQT-rW_0BsCVYBuOaeOhgvhKsgBRLGMxOT-oEr2s2gDIO2uCNb7zvvdISCJbyDgU8BDY-PrlNAM_h4J_NR4rTYp6H0YP5Wue1VjCP0AZzScZqA7wmQPDhn0osAITDwxclo3TTaICtrrV-kK4WAnOLlHHLB_SdRO97CUW0l-oTtiL_UxICb6R87Zs6-0QBhD6GktsJQDtK9vqlmzyACwgdPcHLdriqWo3p87ZcCJZ3dRe-XYArPT9_V2jmxae5D94BzdI8dNNHPa6iut1uo3lDzt9ANWPiAUI3Y__apVilVV4gJj7v5o5ulD-H5XaC_GwJ6ZjSFjgz0Eo4D5MR0MtREvoAvXPXMHbYEGy6QbSDdvth7Ag2HwQbWvyy337_4G-RqKmoaMUiWScFpkVBq7iK-lq2nFdtIikXLM-5zBnlCSuTpIrzpOIiUjXGmMYlFkmWJWm1z-OcipKfM1pkglJO0lhemNJ7rd8uvnakrJ1kncQ50irSrJXahs2DyDUzHUH0S2isfcKunTpL0lgr6-wG4ZTTYV3NGdkJjn7hzLvoCWG4OnVRH8ypwYS9FE2jru_aoVw_tXs-XAg2Hnn57K7j8CK5I9gEppZgs5B9q_FvAAAA___nFV6y">