diff --git a/ChangeLog b/ChangeLog index ce0266a35e..a514dd69a6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2018-06-20 Joseph Myers + * string/tst-cmp.c: Include . + (strncmp_max): Disable -Wstringop-overflow= around call to + strncmp. + (strncasecmp_max): Disable -Wstringop-overflow= around call to + strncasecmp. + * string/bug-strpbrk1.c: Include . (main): Disable -Wunused-value around call to strpbrk. * string/bug-strspn1.c: Include . diff --git a/string/tst-cmp.c b/string/tst-cmp.c index 1a7f1c8b89..3b9f7b2506 100644 --- a/string/tst-cmp.c +++ b/string/tst-cmp.c @@ -26,6 +26,7 @@ #include #include #include +#include static int signum (int val) @@ -98,13 +99,27 @@ strncasecmp_64 (const char *left, const char *right) static int strncmp_max (const char *left, const char *right) { + DIAG_PUSH_NEEDS_COMMENT; +#if __GNUC_PREREQ (7, 0) + /* GCC 9 warns about the size passed to strncmp being larger than + PTRDIFF_MAX; the use of SIZE_MAX is deliberate here. */ + DIAG_IGNORE_NEEDS_COMMENT (9, "-Wstringop-overflow="); +#endif return strncmp (left, right, SIZE_MAX); + DIAG_POP_NEEDS_COMMENT; } static int strncasecmp_max (const char *left, const char *right) { + DIAG_PUSH_NEEDS_COMMENT; +#if __GNUC_PREREQ (7, 0) + /* GCC 9 warns about the size passed to strncasecmp being larger + than PTRDIFF_MAX; the use of SIZE_MAX is deliberate here. */ + DIAG_IGNORE_NEEDS_COMMENT (9, "-Wstringop-overflow="); +#endif return strncasecmp (left, right, SIZE_MAX); + DIAG_POP_NEEDS_COMMENT; } int