| Issue |
115678
|
| Summary |
[clang] Miscompile with -O2/3 and -O0/1
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
cardigan1008
|
When I compiled this code with -O2/3, its return code is 224. With -O0/1, its return code is 0 and its output is 0:
```c
int printf(const char *, ...);
int a, e;
struct b {
int *c;
int d;
};
void f(int g) {
int h[] = {6, e, 4};
int *i = h;
int j = 0;
for (; j < g; j++) {
struct b *k = (struct b *)&i[j];
if (k->c)
k->d = 0;
}
}
int main() {
f(1);
printf("%X\n", a);
}
```
The earliest version with this bug is clang 15.0.0. Details can be found here: https://godbolt.org/z/c4saxe9nq
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs