<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/119646>119646</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Miscompilation at -Os
</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>
This code prints 1 at -Os and 0 at -O0/1/2/3:
```c
int printf(const char *, ...);
long a, b = 208;
short c;
long(d)(long e) { return (a && e && 2036854775807 / e) * a; }
void f(long *e) {
if (d(c | (*e = b || 0)))
for (;;)
;
}
int main() {
long *g = &b;
*g = 0;
f(&b);
printf("%d\n", (int)b);
}
```
Compiler Explorer: https://godbolt.org/z/vPvna9s5Y
Bisected to https://github.com/llvm/llvm-project/commit/ebe741fad07e3fda388d0fa44f256a07429cce6a which was committed by @haopliu
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJyUU02v4yoM_TXOxroVMfkgiyzS9mX39N5iNrMkQBpGaaiA9s6dXz-C3N5Ks5sKqebExz62sQzBXjZjeqiPUJ8LeY-L872SXtuL3ErGRDE5_dF_W2xA5bTBm7dbDFiijPj2X0C5aWT7hQGNJdBIQCMHPgAboGH7UcAGu8WdPgMJ5bYQUS3SI9AAdMLD4QDUAT8CG1a3XVAmdELgZyQm9g9hcT6ienkBCZ1oJDLHAHUI7RG9iXe_IZCQCNQANWieBjHeiLpq21qwFoHGTxoNKIEfEdozsOHhrMb5GRhoeMYGNiDaGffUQiG0p3RJLlntlJAEsqwsHzbg7Hx248d0diz_9mr2rKlJV2m3HO-V7qnhkhMANdNOwhfInsicuc301c1X14EIqNZQn7ZsZt12i0Ddy30X8jW6ZLPh5K43uxqP__y8rc4bD3zAJcZbSJOmEWi8OD25NR6cvwCNv4DGx_-PTXah_o57kKMNRkWjMbo_uTYu9-mg3BVoXNfH8-_t5t0PoyLQqNz1apNhJtNW5Sw1aw2fteRCaDbLqpqpbiRrK-qUMo3E98WqBd9lerqJmzJPHwgVW6S7rfaOhe657ngnC9OXLeddIzhjxdKXsmNGdGxqKtMp1XSmrGviZSlFq01VFbYnRlVJJbGyLit2EK0wSlfElekk7yRUzFylXQ-pjNSTwoZwN31Zdk3VFKuczBry4hGpVaaXTGkHfZ_rnu6XABVbbYjhFSLauOZt3Rn1Gf-1QeXRyGjd9rmVxd2v_V83OOsLaYl3iY-efgcAAP__Y_QooA">