From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from brown.elm.relay.mailchannels.net (brown.elm.relay.mailchannels.net [23.83.212.23]) by sourceware.org (Postfix) with ESMTPS id 180313858405 for ; Mon, 15 Nov 2021 10:41:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 180313858405 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id DB6407206E1 for ; Mon, 15 Nov 2021 10:41:46 +0000 (UTC) Received: from pdx1-sub0-mail-a305.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 9CE6A72077A for ; Mon, 15 Nov 2021 10:41:45 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a305.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.127.242.130 (trex/6.4.3); Mon, 15 Nov 2021 10:41:46 +0000 X-MC-Relay: Junk X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Language-Abortive: 2271534224e69c99_1636972906691_476795721 X-MC-Loop-Signature: 1636972906690:1403089700 X-MC-Ingress-Time: 1636972906690 Received: from [192.168.1.174] (unknown [1.186.223.29]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305.dreamhost.com (Postfix) with ESMTPSA id 4Ht5N825TKz2S for ; Mon, 15 Nov 2021 02:41:43 -0800 (PST) Message-ID: Date: Mon, 15 Nov 2021 16:11:39 +0530 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 Subject: Re: [PATCH 3/3] gimple-fold: Use ranges to simplify strncat and snprintf Content-Language: en-US From: Siddhesh Poyarekar To: gcc-patches@gcc.gnu.org References: <20211111194116.1626980-1-siddhesh@gotplt.org> <20211111194116.1626980-4-siddhesh@gotplt.org> In-Reply-To: <20211111194116.1626980-4-siddhesh@gotplt.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 15 Nov 2021 10:41:57 -0000 On 11/12/21 01:11, Siddhesh Poyarekar wrote: > Remove the warnings for strncat since it is already handled (and even > the error messages look identical) in gimple-ssa-warn-access. Instead, > use len range to determine if it is within bounds of source and > destination and simplify it to strcat if it's safe. > > Likewise for snprintf, use ranges to determine if it can be transformed > to strcpy. > > gcc/ChangeLog: > > * gimple-fold.c (gimple_fold_builtin_strncat): Remove warnings > and use ranges to determine if it is safe to transform to > strcat. > (gimple_fold_builtin_snprintf): Likewise. > > gcc/testsuite/ChangeLog: > > * gcc.dg/fold-stringops-2.c: Define size_t. > (safe1): Adjust. > (safe4): New test. > * gcc.dg/fold-stringops-3.c: New test. > Sorry, it looks like my last test run was stale and didn't catch the regressions dropping warnings caused. I'll bring back the warnings in v2 with ranges. Siddhesh