Open shao-hua-li opened 2 years ago
This might be relevant: https://discourse.llvm.org/t/rfc-safe-optimizations-for-sanitizers/62729
For example 'llvm::mustTriggerUB' should always return false with sanitizers.
https://llvm.org/doxygen/namespacellvm.html#a9b587899173512a007250b3f5307441d
Same for 'mustExecuteUBIfPoisonOnPathTo'
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