Issue |
137588
|
Summary |
【clang】The while loop is lost when in -O1 or higher Optimization level
|
Labels |
clang
|
Assignees |
|
Reporter |
hippyll123
|
in llvm18,the following code will be in an infinite loop at -O0, but not at -O1 or higher Optimization level, Is this expected or bug ? This problem can be avoided by using `-fno-finite-loops` .
In GCC, -O0 or higher Optimization level are all infinite loops.
```
#include <stdio.h>
void bar() {
int a = 0;
int b = 10;
printf("a = %p\n", &a);
while (a < b) {}
printf("b = %p\n", &b);
}
int main() {
bar();
return 0;
}
```
command:
`clang++ --target=x86_64-unknown-linux-gnu 1.cpp -O0 && ./a.out`
`clang++ --target=x86_64-unknown-linux-gnu 1.cpp -O1 && ./a.out`
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs