| Issue |
166694
|
| Summary |
hash.cpp does not error when size_t is an uncommon size
|
| Labels |
|
| Assignees |
|
| Reporter |
ZERICO2005
|
https://github.com/llvm/llvm-project/blob/main/libcxx/src/hash.cpp
```c++
inline void __check_for_overflow(size_t N) {
if constexpr (sizeof(size_t) == 4) {
if (N > 0xFFFFFFFB)
std::__throw_overflow_error("__next_prime overflow");
} else {
if (N > 0xFFFFFFFFFFFFFFC5ull)
std::__throw_overflow_error("__next_prime overflow");
}
}
```
Here `__check_for_overflow` is only defined when `sizeof(size_t)` is 4 or 8. However, no error would be given if `sizeof(size_t)` is some uncommon size like 3 or 2.
In previous versions of llvm (such as llvm 15.0.7 https://github.com/llvm/llvm-project/blob/llvmorg-15.0.7/libcxx/src/hash.cpp), an error would occur if `sizeof(size_t)` was not 4 or 8, which I believe would be a useful diagnostic.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs