From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 121813 invoked by alias); 5 May 2017 16:32:27 -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 121738 invoked by uid 89); 5 May 2017 16:32:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=indeterminate, H*Ad:U*andi X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 05 May 2017 16:32:25 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3970C7D4E7; Fri, 5 May 2017 16:32:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 3970C7D4E7 Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 3970C7D4E7 Received: from tucnak.zalov.cz (ovpn-116-29.ams2.redhat.com [10.36.116.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CFD49777C1; Fri, 5 May 2017 16:32:25 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id v45GWMQ5020077; Fri, 5 May 2017 18:32:23 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id v45GWLl0020073; Fri, 5 May 2017 18:32:21 +0200 Date: Fri, 05 May 2017 16:38:00 -0000 From: Jakub Jelinek To: Martin Sebor Cc: Andi Kleen , gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Re: Make tree-ssa-strlen.c handle partial unterminated strings Message-ID: <20170505163221.GG1809@tucnak> Reply-To: Jakub Jelinek References: <87efw3sebf.fsf@linaro.org> <87efw3gv6b.fsf@firstfloor.org> <20170505155526.GE1809@tucnak> <6a572568-434b-095f-e9c4-ad8e97019d79@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6a572568-434b-095f-e9c4-ad8e97019d79@gmail.com> User-Agent: Mutt/1.7.1 (2016-10-04) X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg00431.txt.bz2 On Fri, May 05, 2017 at 10:28:45AM -0600, Martin Sebor wrote: > There have been requests for a warning to diagnose invalid uses > of character arrays that are not nul-terminated, such as arguments > to functions that expect a (nul-terminated) string. For example: > > char *p = (char*)malloc (20); > memcpy (p, "/tmp/", 5); > strcat (p, "file.text"); // << warn here > > It would be helpful to diagnose such cases (while avoiding false > positives on the indeterminate cases you mention, of course). One thing here is that there is a function known to require a null terminated function, not arbitrary other function that may or might not need it. And another thing is that in the tree-ssa-strlen.c framework known records can be invalidated at any time and you then don't know, it is an optimization, not a warning framework. So, for the warning you'd need to track whether there have been any invalidation and just punt in that case. Jakub