<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/116553>116553</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Miscompile at O3 with SIGKILL
</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>
When I compiled this code with O3, it triggered SIGKILL. With O0/1/2, it returned 0.
Bisected to https://github.com/llvm/llvm-project/commit/5b927130b0e15a442a6ed171f43a612e6a40bbcd, which was committed by @fhahn
Compiler Explorer: https://godbolt.org/z/q9j75feYG
Code:
```c
int printf(const char *, ...);
int a, c, d;
int *b;
char e;
short f;
int g(int i) {
if (i <= 0)
return 1;
int h = 0;
for (; h < i - 1; h++) {
for (; d - h - 1;)
if (c)
b[d] = e = 1;
if (e)
break;
}
return 0;
}
void j() { g(f); }
int main(int i, char *k[]) {
j();
while (0 < f)
;
printf("%X\n", a);
}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVEuTozYQ_jXNpWsoPcCYAwc_4q2pbGoPOWxy1KNBmsXgCHkmm1-fEjD2eHJKFSWkfn7dUn9qmnw3EDVQ7qE8Zuoa3Rgao4L1nRo4Y9tMj_Zn893RgM9oxvPF92QxOj-hGS3hm48Ov0kQB_QRY_BdR4Es_v785dfnr19z_D4bMBAnDuIkVsNA8RoGsshyYEdgu2Xd-4lMTAlGdDFeJpA7ECcQp85Hd9W5Gc8gTn3_-v57uoTxhUwEcTLj-ezTptS1qLhkmhEvVVEItSHLK94WUm24oI0qmNbGJixvzhuHbyqVk9xTcv0ToWCtU27Aj-gOS_kBf_n70o-BAsjdZ5ij1WMf8zF0IE7_gDj9Vb9UZUt_fnmMZCn5LKINWz6znP0Q8RL8EFsQWzMOU0TjVEAQu4Q4z3MQNcj93VoluUmLfZCD2OmbYI5Bt-PkxhCxfbDvQGzT34OoEapVg-hbTBoEeQB5RJbyrypcrxL5LRJiiuFwMb1L2zHVsAW5n5UH9Pg0u6EDsZ-_h6wPHhaf0K32D-nf0ZlPUkQN5d5CeZyB0Lx-ALl40ScvHUj9-IAZquP7dq3zXtFN9zp6iy8J6FLA3Md2uaR7hNSUs_LDvceH273-WAbwUwPWkB_gvDnfU8LN5ga2D-jvdrfXA0KAKP-A8jDM20N6KvV_K7g9wcw20tayVhk1vJJ8u6llJTPXkKaCt1SamgttWCG2FZEpi1oXStUtZb4RTBSc84pvi1rKfKssb9tKm7auNa8MFIzOyvd5Gts0IJmfpis1nG_KUma90tRPMxMJYXo1dAlxecxCM8-5vnYTFKz3U5zuIaKP_Uxfi0d5xN_8tNIUqojf5MJQKx1l19A3_5tYZpxTYrAF6msj_g0AAP__5nVt5g">