From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 64351 invoked by alias); 15 Nov 2017 15:13:05 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 64341 invoked by uid 89); 15 Nov 2017 15:13:05 -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,KAM_SHORT,KB_WAM_FROM_NAME_SINGLEWORD,RCVD_IN_DNSWL_NONE,SPF_PASS,URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Nov 2017 15:13:02 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-MBX-04.mgc.mentorg.com) by relay1.mentorg.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-SHA384:256) id 1eEzN4-0004X3-QY from Tom_deVries@mentor.com ; Wed, 15 Nov 2017 07:12:58 -0800 Received: from [172.30.72.60] (137.202.0.87) by SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) with Microsoft SMTP Server (TLS) id 15.0.1320.4; Wed, 15 Nov 2017 15:12:54 +0000 Subject: [testsuite, committed] Compile strncpy-fix-1.c with -Wno-stringop-truncation To: Martin Sebor , Jeff Law , Gcc Patch List References: <13944863-99a8-4144-1703-c6e1a2f36425@gmail.com> <0bbc91cd-fcdb-be61-e1d0-4b230f23b1a9@redhat.com> <4f4fbd4c-cb46-b80d-5749-ebb6bb050bc4@gmail.com> From: Tom de Vries Message-ID: <096cf240-55e1-37e1-2810-0594a76492c0@mentor.com> Date: Wed, 15 Nov 2017 15:30:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------A28A90FB5BF76E64D595303B" X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To SVR-IES-MBX-04.mgc.mentorg.com (139.181.222.4) X-SW-Source: 2017-11/txt/msg01211.txt.bz2 --------------A28A90FB5BF76E64D595303B Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-length: 1868 [ Re: [PATCH 3/4] enhance overflow and truncation detection in strncpy and strncat (PR 81117) ] On 08/06/2017 10:07 PM, Martin Sebor wrote: > Part 3 of the series contains the meat of the patch: the new > -Wstringop-truncation option, and enhancements to -Wstringop- > overflow, and -Wpointer-sizeof-memaccess to detect misuses of > strncpy and strncat. > > Martin > > gcc-81117-3.diff > > > PR c/81117 - Improve buffer overflow checking in strncpy > > gcc/testsuite/ChangeLog: > > PR c/81117 > * c-c++-common/Wsizeof-pointer-memaccess3.c: New test. > * c-c++-common/Wstringop-overflow.c: Same. > * c-c++-common/Wstringop-truncation.c: Same. > * c-c++-common/Wsizeof-pointer-memaccess2.c: Adjust. > * c-c++-common/attr-nonstring-2.c: New test. > * g++.dg/torture/Wsizeof-pointer-memaccess1.C: Adjust. > * g++.dg/torture/Wsizeof-pointer-memaccess2.C: Same. > * gcc.dg/torture/pr63554.c: Same. > * gcc.dg/Walloca-1.c: Disable macro tracking. > Hi, this also caused a regression in strncpy-fix-1.c. I noticed it for nvptx (but I also saw it in other test results, f.i. for x86_64-unknown-freebsd12.0 at https://gcc.gnu.org/ml/gcc-testresults/2017-11/msg01276.html ). On linux you don't see this unless you add -Wsystem-headers: ... $ gcc src/gcc/testsuite/gcc.dg/strncpy-fix-1.c -fno-diagnostics-show-caret -fdiagnostics-color=never -O2 -Wall -Wsystem-headers -S -o strncpy-fix-1.s In file included from /usr/include/string.h:630, from src/gcc/testsuite/gcc.dg/strncpy-fix-1.c:6: src/gcc/testsuite/gcc.dg/strncpy-fix-1.c: In function ‘f’: src/gcc/testsuite/gcc.dg/strncpy-fix-1.c:10:3: warning: ‘__builtin_strncpy’ output truncated before terminating nul copying 2 bytes from a string of the same length [-Wstringop-truncation] ... Fixed by adding -Wno-stringop-truncation. Committed as obvious. Thanks, - Tom --------------A28A90FB5BF76E64D595303B Content-Type: text/x-patch; name="0001-Compile-strncpy-fix-1.c-with-Wno-stringop-truncation.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0001-Compile-strncpy-fix-1.c-with-Wno-stringop-truncation.pa"; filename*1="tch" Content-length: 738 Compile strncpy-fix-1.c with -Wno-stringop-truncation 2017-11-15 Tom de Vries * gcc.dg/strncpy-fix-1.c: Add -Wno-stringop-truncation to dg-options. --- gcc/testsuite/gcc.dg/strncpy-fix-1.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/testsuite/gcc.dg/strncpy-fix-1.c b/gcc/testsuite/gcc.dg/strncpy-fix-1.c index b8bc916..b4fd4aa 100644 --- a/gcc/testsuite/gcc.dg/strncpy-fix-1.c +++ b/gcc/testsuite/gcc.dg/strncpy-fix-1.c @@ -1,7 +1,7 @@ /* Test that use of strncpy does not result in a "value computed is not used" warning. */ /* { dg-do compile } */ -/* { dg-options "-O2 -Wall" } */ +/* { dg-options "-O2 -Wall -Wno-stringop-truncation" } */ #include void --------------A28A90FB5BF76E64D595303B--