From patchwork Wed Jun 20 22:20:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 27958 Received: (qmail 27109 invoked by alias); 20 Jun 2018 22:20:32 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 27093 invoked by uid 89); 20 Jun 2018 22:20:31 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Wed, 20 Jun 2018 22:20:24 +0000 From: Joseph Myers To: Subject: Fix tst-cmp.c build with GCC mainline [committed] Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) Building the testsuite with GCC mainline fails with -Wstringop-overflow= errors in string/tst-cmp.c. These are for calls to strncmp and strncasecmp with SIZE_MAX size argument. The tests are deliberately using this size that would be dubious in normal code, so this patch disables the warning for the calls in question. Tested with build-many-glibcs.py for aarch64-linux-gnu. Committed. 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. diff --git a/string/tst-cmp.c b/string/tst-cmp.c index 1a7f1c8..3b9f7b2 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