summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNick Desaulniers <nickdesaulniers@users.noreply.github.com>2024-01-05 08:19:04 -0800
committerGitHub <noreply@github.com>2024-01-05 08:19:04 -0800
commit5352ce32fccd37c54aff2b3a2b0e3ca5115bb8a9 (patch)
treec9844e375b9a157ca54dec9d3830a8087988d0e6
parente2972389111e30a93a21cf8c5f4d2284cbb60268 (diff)
[libc] fix -Warray-bounds in block_offset (#77001)
GCC reports an instance of -Warray-bounds in block_offset. Reimplement block_offset in terms of memcpy_inline which was created to avoid this diagnostic. See the linked issue for the full trace of diagnostic. Fixes: https://github.com/llvm/llvm-project/issues/76877
-rw-r--r--libc/src/string/memory_utils/op_builtin.h8
1 files changed, 1 insertions, 7 deletions
diff --git a/libc/src/string/memory_utils/op_builtin.h b/libc/src/string/memory_utils/op_builtin.h
index 16c9f519c37e..3c17eef781e5 100644
--- a/libc/src/string/memory_utils/op_builtin.h
+++ b/libc/src/string/memory_utils/op_builtin.h
@@ -26,13 +26,7 @@ template <size_t Size> struct Memcpy {
static constexpr size_t SIZE = Size;
LIBC_INLINE static void block_offset(Ptr __restrict dst, CPtr __restrict src,
size_t offset) {
-#ifdef LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE
- return __builtin_memcpy_inline(dst + offset, src + offset, SIZE);
-#else
- // The codegen may be suboptimal.
- for (size_t i = 0; i < Size; ++i)
- dst[i + offset] = src[i + offset];
-#endif
+ memcpy_inline<Size>(dst + offset, src + offset);
}
LIBC_INLINE static void block(Ptr __restrict dst, CPtr __restrict src) {