[libc-commits] [libc] [libc] Fix casts for arm32 after Wconversion (PR #129771)
Michael Jones via libc-commits
libc-commits at lists.llvm.org
Wed Mar 5 10:20:41 PST 2025
michaelrj-google wrote:
It's not that `array` handles negatives, it's that the `at` lambda is only used in `safe_get_at`, and the `safe_get_at` function does the bounds checking:
```
const auto safe_get_at = [&](size_t index) -> word {
// return appropriate value when accessing out of bound elements.
const int i = at(index);
if (i < 0)
return 0;
if (i >= int(N))
return is_neg ? cpp::numeric_limits<word>::max() : 0;
return array[i];
};
```
If `i` is negative or greater than the size of the size of the array, it returns before it attempts to index into `array`.
https://github.com/llvm/llvm-project/pull/129771
More information about the libc-commits
mailing list