Issue |
116483
|
Summary |
[clang] Miscompile at O3 with SIGKILL
|
Labels |
clang
|
Assignees |
|
Reporter |
cardigan1008
|
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/254da5ab8bce846bcbac9862f31c1891d8feea44, which was committed by @RKSimon
Compiler Explorer: https://godbolt.org/z/oE87zTxGf
Code:
```c
int printf(const char *, ...);
int a, b, c, e, f;
long k, l;
void m(int n) {
b = 1;
for (; b <= n; b++)
for (; c; c++)
;
}
long o(long n) {
long g = 0, i = 1, j = n;
char h = 0;
while (j > 0) {
char d = j & i;
if (d)
g += i << h;
j >>= 1;
h++;
}
g *= h % 2 == 0 ? 2 : 3;
return g;
}
long p(unsigned short n) {
for (; e;)
if (f)
return 0;
return n;
}
int main() {
k = o(207 + 122);
l = p((char)k);
m(l);
printf("%X\n", a);
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs