Issue |
55676
|
Summary |
clang aggresively optimized away UBs
|
Labels |
|
Assignees |
|
Reporter |
shao-hua-li
|
For the following code, ASan with clang -O2 and above did not produce any warning of the buffer overflow in function a. I understand that optimizers could assume UBs never happen and do whatever they want to optimize the code. But I do concern that such aggressiveness would hinder the effectiveness of sanitizers. A similar issue is discussed in https://github.com/llvm/llvm-project/issues/53972 and current belief is that this should not be an issue.
On this specific case, gcc however tends to be less aggressive than Clang.
https://godbolt.org/z/9MTWeGjzM
```c
int a() {
int b[7];
for (int e = 0; e < 8; e++)
b[e] = 6;
return b[1];
}
int main() {
return a();
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs