Issue |
147326
|
Summary |
UBSan (unsigned-integer-overflow) reports issue in libc++
|
Labels |
libc++
|
Assignees |
|
Reporter |
oboukli
|
Compiler info:
```text
clang version 20.1.0 (https://github.com/llvm/llvm-project.git 24a30daaa559829ad079f2ff7f73eb4e18095f88)
Target: x86_64-unknown-linux-gnu
```
```cpp
#include <algorithm>
#include <functional>
#include <vector>
int main()
{
std::vector primes{
2, 3, 5, 7, 11, 13, 17, 19,
23, 29, 31, 37, 41, 43, 47, 53,
59, 61, 67, 71, 73, 79, 83, 89,
};
std::sort(primes.begin(), primes.end(), std::greater{});
return 0;
}
```
Compile with `-stdlib=libc++ -fsanitize=unsigned-integer-overflow`
Output:
```text
/opt/compiler-explorer/clang-20.1.0/bin/../include/c++/v1/__bit/blsr.h:25:23: runtime error: negation of 1023 cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /opt/compiler-explorer/clang-20.1.0/bin/../include/c++/v1/__bit/blsr.h:25:23
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs