| Issue |
64757
|
| Summary |
UBsan misses the shift index is negative
|
| Labels |
new issue
|
| Assignees |
|
| Reporter |
Vanish-Zeng
|
Compiler explorer: https://godbolt.org/z/dnTzPMY93
For the following code, all opt levels of clang's UBSan can not capture the runtime error (i.e. the shift index is negative), while gcc can.
\% cat bug.c
```c
int printf(const char *, ...);
int main()
{
unsigned short a, b = 35204;
a = 96 << -17658 ? 796349297U : b;
printf("%u\n", a);
}
```
\%
\% clang -fsanitize=undefined bug.c && ./a.out
35204
\%
\% gcc -fsanitize=undefined bug.c && ./a.out
/app/bug.c:5:12: runtime error: shift exponent -17658 is negative
21361
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs