Skip to content

Commit 5352ce3

Browse files
[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: #76877
1 parent e297238 commit 5352ce3

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

libc/src/string/memory_utils/op_builtin.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,7 @@ template <size_t Size> struct Memcpy {
2626
static constexpr size_t SIZE = Size;
2727
LIBC_INLINE static void block_offset(Ptr __restrict dst, CPtr __restrict src,
2828
size_t offset) {
29-
#ifdef LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE
30-
return __builtin_memcpy_inline(dst + offset, src + offset, SIZE);
31-
#else
32-
// The codegen may be suboptimal.
33-
for (size_t i = 0; i < Size; ++i)
34-
dst[i + offset] = src[i + offset];
35-
#endif
29+
memcpy_inline<Size>(dst + offset, src + offset);
3630
}
3731

3832
LIBC_INLINE static void block(Ptr __restrict dst, CPtr __restrict src) {

0 commit comments

Comments
 (0)