From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 84573 invoked by alias); 17 Jul 2018 07:52:55 -0000 Mailing-List: contact fortran-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: fortran-owner@gcc.gnu.org Received: (qmail 84411 invoked by uid 89); 17 Jul 2018 07:52:42 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=3.6 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPAM_BODY,SPF_PASS autolearn=no version=3.3.2 spammy=tone, tons, taste, H*i:sk:CAKwh3q X-HELO: mail-yw0-f169.google.com Received: from mail-yw0-f169.google.com (HELO mail-yw0-f169.google.com) (209.85.161.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 17 Jul 2018 07:52:41 +0000 Received: by mail-yw0-f169.google.com with SMTP id r3-v6so60453ywc.5; Tue, 17 Jul 2018 00:52:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc:content-transfer-encoding; bh=sgWsgmWMDtYW9QAqL14fiSNAo9cnWN73G7QfqN8by/8=; b=p3I1dzHyHD8o8+CfC+9+XofuYdA+JdzIzy80mwGj4+wD95u3WW7J7E+vNzHfJhPsn7 UDyFG+i2TH84inq/7pPp+cLgOAregXAoJEFNQVhlCRYT9C6snHokEeR7NOST7fKZi3dy tdnZu25pS5go5+cddV9raeZmfbYkq02HW/QI0DTvldJ0ABBSVKWWcbbSIjxbgjqNIisd ywiO2pwf3+6bvnCT54NmlklYMbv2+V4OHEpHCMV1017b/XpgkGEPbwUBzI96FYs5rhsv xJsqtBnNI1ZNAxzr160kj4zTKTLS/ScrepcV+m1fliE2fYeYAbBPMdu11txtfTph9qoA MCVA== MIME-Version: 1.0 Sender: jaydub66@gmail.com Received: by 2002:a0d:ea0c:0:0:0:0:0 with HTTP; Tue, 17 Jul 2018 00:52:39 -0700 (PDT) In-Reply-To: References: <7ce70d80-88ac-f2cb-89cc-d622ac873b9e@netcologne.de> From: Janus Weil Date: Tue, 17 Jul 2018 07:52:00 -0000 Message-ID: Subject: Re: [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions To: Thomas Koenig Cc: gfortran , gcc-patches Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg00050.txt.bz2 > 2018-07-16 21:50 GMT+02:00 Thomas Koenig : >> What I would suggest is to enable -Wfunction-eliminiation with >> -Wextra and also use that for your new warning. > > Thanks for the comments. Makes sense. Updated patch attached. Huh, after actually trying -Wfunction-elimination, I'm not so sure any more if it really makes sense to throw the new warnings in there, mainly for two reasons: a) -Wfunction-elimination is slightly different, in that it warns about removing *any* kind of function, not just impure ones. This makes it pretty verbose, and I'm not sure why one would need to know if a pure function call is removed. b) It gives warnings on places that I don't understand. Simple example: subroutine sub(r) implicit none real, intent(in) :: r if ((abs(r) > 1e6) .or. (abs(r) < 1e-6)) then print *, "rrr" end if end Compiling this with "gfortran-8 -O1 -Wfunction-elimination" gives me: if ((abs(r) > 1e6) .or. (abs(r) < 1e-6)) then 1 Warning: Removing call to function =E2=80=98abs=E2=80=99 at (1) [-Wfunction= -elimination] Why can I remove the call to ABS there? If I read the dump correctly, then the two calls to ABS are optimized into a single one, which is used for both comparisons via a temporary. Is that what the warning is trying to tell me? And if yes, why should I care (if the function is pure)? The middle-end certainly does tons of optimizations that rearrange various expressions, without warning me about it ... In other words: Does it make sense to tone down -Wfunction-elimination, by only warning about impure functions? (We certainly have the diagnostic capabilites for this.) If not, I'd rather have a separate flag for the new warnings. -Wfunction-elimination is just too noisy for my taste in its current form. Cheers, Janus