`-fwrapv` incorrectly disables `-fsanitize=undefined` catching `-2147483648 % -1`
Open
compiler-rt:ubsan
llvm:optimizations
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
This program:
```c
int main() {
int a = 1U << 31;
int b = a % -1;
}
```
compiled with `-fwrapv -fsanitize=undefined`, crashes with `UndefinedBehaviorSanitizer: FPE on unknown address`, instead of properly detecting and reporting overflow as it does when ran without `-fwrapv` (note that `-fwrapv` does not prevent this operation being UB - the program still `SIGFPE`s when compiled with just `-fwrapv`).
And, combined with `-O1` or greater, will result in no sanitizer warnings at all.
The same applies to division:
```c
int main() {
int a = 1U << 31;
int b = a / -1;
}
```
https://godbolt.org/z/h9GK47fK7
Contributor guide
Assessment
This issue has not been assessed yet.