From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6307 invoked by alias); 21 Feb 2018 03:56:17 -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 6296 invoked by uid 89); 21 Feb 2018 03:56:16 -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,T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= 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; Wed, 21 Feb 2018 03:56:15 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4187085A05; Wed, 21 Feb 2018 03:56:14 +0000 (UTC) Received: from localhost.localdomain (ovpn-112-67.rdu2.redhat.com [10.10.112.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0971C60BE5; Wed, 21 Feb 2018 03:56:12 +0000 (UTC) Subject: Re: [PATCH] Fix pdftex miscompilation due to get_range_strlen (PR tree-optimization/84478, take 2 and 3) To: Jakub Jelinek , Richard Biener , Martin Sebor Cc: gcc-patches@gcc.gnu.org References: <20180220171712.GH5867@tucnak> <20180220213446.GK5867@tucnak> From: Jeff Law Message-ID: <1f113162-6ffb-6962-0ba4-258b82bb062f@redhat.com> Date: Wed, 21 Feb 2018 03:56:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180220213446.GK5867@tucnak> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2018-02/txt/msg01213.txt.bz2 On 02/20/2018 02:34 PM, Jakub Jelinek wrote: > On Tue, Feb 20, 2018 at 01:13:13PM -0700, Martin Sebor wrote: >> A safer and even more conservative alternative that should be >> equivalent to your approach while avoiding the sprintf regressions >> is to add another mode to the function and have it clear *minlen >> as an option. This lets the strlen code obtain the conservative >> lower bound without compromising the sprintf warnings. > > I fail to see what it would be good for to set *MINLEN to zero and > *MAXLEN to all ones for the non-warning use cases, we simply don't know > anything about it, both NULL_TREEs i.e. returning false is better. I'm > offering two alternate patches which use > fuzzy == 0 for the previous !fuzzy, fuzzy == 1 for conservatively correct > code that assumes strlen can't cross field/variable boundaries in > compliant programs and fuzzy == 2 which does that + whatever the warning > code wants. Additionally, I've rewritten the COND_EXPR handling, so that > it matches exactly the PHI handling. > > The first patch doesn't change the 2 argument get_range_strlen and changes > gimple_fold_builtin_strlen to use the 6 argument one, the second patch > changes also the 2 argument get_range_strlen similarly to what you've done > in your patch. > > Tested on x86_64-linux and i686-linux, ok for trunk if it passes > bootstrap/regtest? Which one? I'd lean towards the second -- essentially trying to keep the 6 operand version for internal (recursive) use only. In my mind I'd like to encapsulate the 6 operand version so that it can't be directly called and the only public interface is the 3 operand version using strict/no-strict. Let's go with that. We can try to clean this up further during gcc-9. Jeff