[libc-commits] [libc] [libc] Add `-Wsign-conversion` & un-reverts `-Wconversion` (PR #129811)

Vinay Deshmukh via libc-commits libc-commits at lists.llvm.org
Fri Mar 7 18:24:03 PST 2025


================
@@ -296,7 +296,7 @@ LIBC_INLINE constexpr cpp::array<word, N> shift(cpp::array<word, N> array,
   for (size_t index = 0; index < N; ++index) {
     const word part1 = safe_get_at(index + index_offset);
     const word part2 = safe_get_at(index + index_offset + 1);
-    word &dst = out[at(index)];
+    word &dst = out[static_cast<size_t>(at(index))];
----------------
vinay-deshmukh wrote:

Looks like it works without raising a warning.

May I know what the difference would be here? AFAIK casting doesn't really change the type here (i guess) but only silences the warning? and `unsigned` would still be auto-promoted to `size_t` eventually?

https://github.com/llvm/llvm-project/pull/129811


More information about the libc-commits mailing list