]> sourceware.org Git - glibc.git/commitdiff
string: Fix GCC 11 `-Werror=stringop-overread' error
authorMaciej W. Rozycki <macro@wdc.com>
Mon, 31 Aug 2020 13:26:47 +0000 (14:26 +0100)
committerJoseph Myers <joseph@codesourcery.com>
Mon, 7 Sep 2020 17:01:06 +0000 (17:01 +0000)
Fix a compilation error:

In function '__rawmemchr',
    inlined from '__rawmemchr' at rawmemchr.c:27:1:
rawmemchr.c:36:12: error: 'memchr' specified bound 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Werror=stringop-overread]
   36 |     return memchr (s, c, (size_t)-1);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
../o-iterator.mk:9: recipe for target '.../string/rawmemchr.o' failed

introduced with GCC 11 commit d14c547abd48 ("Add -Wstringop-overread
for reading past the end by string functions.").

string/rawmemchr.c

index b62d285d7efa882b3928fae03318273d588f15bd..d6ce8209be9c7248434e875b69758633fb7f0a9d 100644 (file)
@@ -31,6 +31,10 @@ RAWMEMCHR (const void *s, int c)
   /* GCC 8 warns about the size passed to memchr being larger than
      PTRDIFF_MAX; the use of SIZE_MAX is deliberate here.  */
   DIAG_IGNORE_NEEDS_COMMENT (8, "-Wstringop-overflow=");
+#endif
+#if __GNUC_PREREQ (11, 0)
+  /* Likewise GCC 11, with a different warning option.  */
+  DIAG_IGNORE_NEEDS_COMMENT (11, "-Wstringop-overread");
 #endif
   if (c != '\0')
     return memchr (s, c, (size_t)-1);
This page took 0.04273 seconds and 5 git commands to generate.