From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 128946 invoked by alias); 4 Feb 2020 19:15:53 -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 128905 invoked by uid 89); 4 Feb 2020 19:15:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-3.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=H*i:sk:8ce15b9, H*f:sk:8ce15b9 X-HELO: mail-wm1-f67.google.com Received: from mail-wm1-f67.google.com (HELO mail-wm1-f67.google.com) (209.85.128.67) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 04 Feb 2020 19:15:50 +0000 Received: by mail-wm1-f67.google.com with SMTP id s10so4562674wmh.3 for ; Tue, 04 Feb 2020 11:15:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:user-agent:in-reply-to:references:mime-version :content-transfer-encoding:subject:to:cc:from:message-id; bh=vVrhzkMic1i2v5fVmKeJHGMROHOHApEcs4dDl9LEprk=; b=TyehT6ijW84HW1XMJ3plbs+gN7nP83HZLJjeBWFRgBEDa/KWjYyJCPAj0FqeHr2TEK iDoFnhm7TxY1FfCHoJWeAQL3WUCTPPEceDIl3yPFFJImBucNZ0tM/bIWGRBnLgilJLcJ oJzefW/PLGD+2wc1GSvqjSyaTgFu9WEJx2AkQMT58Ot9rfHABhAsRna5yWJ8EKztZwOk oPdnlhZpyYqvYGE6Q26TODSPB6tAMJLW/GovXivAPE6d1g/7bLmrDvXdIrH7/Y5yN8YZ x5ReeODYx/KALTzWJAbFWjcL8sqEuvO9WdIMjqCGj8kMpwf3KTSke3x+nc+MMh4qW6u7 1ilw== Return-Path: Received: from [192.168.178.32] (x5f767d26.dyn.telefonica.de. [95.118.125.38]) by smtp.gmail.com with ESMTPSA id e22sm28765869wrc.13.2020.02.04.11.15.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Feb 2020 11:15:47 -0800 (PST) Date: Tue, 04 Feb 2020 19:15:00 -0000 User-Agent: K-9 Mail for Android In-Reply-To: <8ce15b9656ca4c66f5ded087a8cfb63a1ae9eefb.camel@redhat.com> References: <6d253aa7-7f51-895b-b5db-d32ddb79cefc@gmail.com> <8ce15b9656ca4c66f5ded087a8cfb63a1ae9eefb.camel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PATCH] avoid issuing -Wrestrict from folder (PR 93519) To: law@redhat.com,Jeff Law ,Martin Sebor CC: gcc-patches From: Richard Biener Message-ID: X-IsSubscribed: yes X-SW-Source: 2020-02/txt/msg00215.txt.bz2 On February 4, 2020 5:30:42 PM GMT+01:00, Jeff Law wrote: >On Tue, 2020-02-04 at 10:34 +0100, Richard Biener wrote: >> On Tue, Feb 4, 2020 at 1:44 AM Martin Sebor wrote: >> > PR 93519 reports a false positive -Wrestrict issued for an inlined >call >> > to strcpy that carefully guards against self-copying. This is >caused >> > by the caller's arguments substituted into the call during inlining >and >> > before dead code elimination. >> >=20 >> > The attached patch avoids this by removing -Wrestrict from the >folder >> > and deferring folding perfectly overlapping (and so undefined) >calls >> > to strcpy (and mempcpy, but not memcpy) until much later. Calls to >> > perfectly overlapping calls to memcpy are still folded early. >>=20 >> Why do we bother to warn at all for this case? Just DWIM here.=20 >Warnings like >> this can be emitted from the analyzer? >They potentially can, but the analyzer is and will almost always >certainly be considerably slower. I would not expect it to be used >nearly as much as the core compiler. > >WHether or not a particular warning makes sense in the core compiler or >analyzer would seem to me to depend on whether or not we can reasonably >issue warnings without interprocedural analysis. double-free >realistically requires interprocedural analysis to be effective. I'm >not sure Wrestrict really does. > > >>=20 >> That is, I suggest to simply remove the bogus warning code from >folding >> (and _not_ fail the folding). >I haven't looked at the patch, but if we can get the warning out of the >folder that's certainly preferable. And we could investigate deferring >self-copy removal. I think the issue is as usual, warning for code we'll later remove as dead.= Warning at folding is almost always premature.=20 Richard.=20 >Jeff