<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/121745>121745</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Miscompilation at -O2/3
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
cardigan1008
</td>
</tr>
</table>
<pre>
This code prints 8 at `-O0/1` and prints 1 at `-O2/3`:
```c
int printf(const char *, ...);
static char a;
static char *b = &a;
static int c;
short d;
void e() {
short f[8];
char **g[] = {&b, &b};
c = 0;
for (; c < 8; c = 81 + 462704684 + *b - 462704765 + c + 1)
f[c] = 0;
d = f[5];
}
int main() {
e();
printf("%d\n", c);
}
```
Compiler Explorer: https://godbolt.org/z/MEKz8oncP
Bisected to https://github.com/llvm/llvm-project/commit/df4a615c988f3ae56f7e68a7df86acb60f16493a, which was committed by @fhahn
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUU81uvDYQf5rhMsrKDNiYA4f9CJcqag99AWObxRWLV9ibNHn6ymZ306anv2Rhz_zm-8eoENx5sbYDfgB-KtQtTn7ttFqNO6ulZEwWgzef3Z-TC6i9sXhd3RIDSlQRQbCX3xlQX4JgqBbzQMsnSkB9BYJBtQeWj2Db0cD2bombywgktV9CRD2pFYH2QEfc7XZALVQHYPsQVXR6g9X_VUD7AaE6IZD4L5xy6Ltm8mtEswnv3hm0QBKoRWiSCnGzGIEfJPDTZoj_qml_3ia1pWoOQGJIlea7-XbIOHuIo0_uEqpDRo74fJ5Qlgh0wFpQw2oh6yzlbl7uykbwrNT5W6aJpKCYy9SPYp7JTBYTxp8tpNK2aV-UW370fJ_B3f9JBxABcQP8uOTnEfXTaov3pHJj9ugvVzfbFV__vs5-tStUe5xivIZEPvVA_dmbwc9x59czUP8F1L-9_vYl_aL_2GIcXLA6WoPR_3R1cboNO-0vQP08vz-ul-vq_7I6AvXaXy4uPcxYK1Fy3Uo5VspyMTZWSNWYUQqlB8HGUtRtpVJTH5PTE36o9Hsn95R8-ESo2TipacHCdJVpq1YVtiubSpS8JcaKqSPeNnw0zSDGoW1Ma7UqjZGDslKLuhoL1xEjzkomSkaiZjshWyGGljFjhlJUAmpmL8rNu9RHmknhQrjZrqSyqXkxq8HOIa8m0WI_MKOJC34q1i43P9zOAWo2uxDDd5jo4my7Nxd0pkRF55e0kfd1LG7r3P3ydHP2kJZ9K--9o38CAAD__2SnMKg">