[libcxx-commits] [libcxx] [libc++] Fix bogus integer sanitizer warnings in hash helpers (PR #146715)
Jean-Michaƫl Celerier via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Jul 3 15:17:51 PDT 2025
jcelerier wrote:
here's for instance the messages I'm getting: (values come from a call I had in one of my ubsan backtraces)
```cpp
#include <iostream>
using _Size = unsigned long;
static _Size __rotate(_Size __val, int __shift) {
return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift)));
}
int main() {
std::cout << __rotate(17751278790833232267U, 43) << "\n";
}
```
```
$ clang++ -Wextra -Wall foo.cpp -fsanitize=undefined -fsanitize=address -fsanitize=integer -g && ./a.out
foo.cpp:5:64: runtime error: left shift of 17751278790833232267 by 21 places cannot be represented in type '_Size' (aka 'unsigned long')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior foo.cpp:5:64
```
I tried disabling only "shift" instead of the wholesale "integer" but it didn't fix the warning
https://github.com/llvm/llvm-project/pull/146715
More information about the libcxx-commits
mailing list