Skip to content

Commit bc4f3e3

Browse files
authored
[libc][NFC] Selectively disable GCC warnings (#78462)
1 parent 51e3d2f commit bc4f3e3

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

libc/src/string/memory_utils/op_x86.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ LIBC_INLINE MemcmpReturnType cmp_neq<uint64_t>(CPtr p1, CPtr p2,
116116
return cmp_neq_uint64_t(a, b);
117117
}
118118

119+
// SIMD types are defined with attributes. e.g., '__m128i' is defined as
120+
// long long __attribute__((__vector_size__(16), __aligned__(16)))
121+
// When we use these SIMD types in template specialization GCC complains:
122+
// "ignoring attributes on template argument ‘__m128i’ [-Wignored-attributes]"
123+
// Therefore, we disable this warning in this file.
124+
#pragma GCC diagnostic push
125+
#pragma GCC diagnostic ignored "-Wignored-attributes"
126+
119127
///////////////////////////////////////////////////////////////////////////////
120128
// Specializations for __m128i
121129
#if defined(__SSE4_1__)
@@ -304,6 +312,8 @@ LIBC_INLINE MemcmpReturnType cmp_neq<__m512i>(CPtr p1, CPtr p2, size_t offset) {
304312
}
305313
#endif // __AVX512BW__
306314

315+
#pragma GCC diagnostic pop
316+
307317
} // namespace LIBC_NAMESPACE::generic
308318

309319
#endif // LIBC_TARGET_ARCH_IS_X86_64

libc/src/string/memory_utils/utils.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@ LIBC_INLINE void memcpy_inline(void *__restrict dst,
8989
// In memory functions `memcpy_inline` is instantiated several times with
9090
// different value of the Size parameter. This doesn't play well with GCC's
9191
// Value Range Analysis that wrongly detects out of bounds accesses. We
92-
// disable the 'array-bounds' warning for the purpose of this function.
92+
// disable these warnings for the purpose of this function.
9393
#pragma GCC diagnostic push
9494
#pragma GCC diagnostic ignored "-Warray-bounds"
95+
#pragma GCC diagnostic ignored "-Wstringop-overread"
96+
#pragma GCC diagnostic ignored "-Wstringop-overflow"
9597
for (size_t i = 0; i < Size; ++i)
9698
static_cast<char *>(dst)[i] = static_cast<const char *>(src)[i];
9799
#pragma GCC diagnostic pop

0 commit comments

Comments
 (0)