From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13574 invoked by alias); 12 Jul 2018 14:55:57 -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 13554 invoked by uid 89); 12 Jul 2018 14:55:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.7 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 spammy=typical, fight, H*f:sk:3D4B88C, non-portable X-HELO: mail-yb0-f174.google.com Received: from mail-yb0-f174.google.com (HELO mail-yb0-f174.google.com) (209.85.213.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 12 Jul 2018 14:55:55 +0000 Received: by mail-yb0-f174.google.com with SMTP id i9-v6so11499588ybo.5; Thu, 12 Jul 2018 07:55:55 -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=Nd5ei8AHeuAb88GlBQTRnj71rKSZjxHOZ+Wwcex31zI=; b=Peg0u8YdSA27zLjJ2DXxAwXLiZDdk7idG+zukrez/ABe1cX9HYpiBpD9vE5OWkfCfX YtJPOnnRLSMXH1fCE5mhNgMG8B2uS8zTvfjOxP7B0AKbPpceNjzNaCxQ2hXZzqo4tC2p FQwHftCyGPSK/cmrBVw8+HBElhzsoCsf4zyMkxHAAN30rJrLQ3fzC7i/YUtGa6UDx73v rTpJmaWJfVzjyAMOj6oT1nDs/HJgpuNpRvoq+BiZE8zG6wwBgQc2DzrgCtKrblA+dEDI yC19lgSXe+cUhLH2V8AAA19ixjjpCWnIVYvnSKgPx4w2M/X95kZ8JwMv6ZaohwtsllCm nkyA== MIME-Version: 1.0 Sender: jaydub66@gmail.com Received: by 2002:a81:9a13:0:0:0:0:0 with HTTP; Thu, 12 Jul 2018 07:55:53 -0700 (PDT) In-Reply-To: References: <3D4B88C8-39B3-4E6C-9FA0-4EB6F80788B5@lps.ens.fr> From: Janus Weil Date: Thu, 12 Jul 2018 14:55:00 -0000 Message-ID: Subject: Re: [Patch, Fortran] PR 85599: warn about short-circuiting of logical expressions for non-pure functions To: =?UTF-8?Q?Dominique_d=27Humi=C3=A8res?= 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/msg00022.txt.bz2 2018-07-12 16:35 GMT+02:00 Dominique d'Humi=C3=A8res : > >>>> after the dust of the heated discussion around this PR has settled a >>>> bit, here is another attempt to implement at least some basic warnings >>>> about compiler-dependent behavior concerning the short-circuiting of >>>> logical expressions. =E2=80=A6 >>> >>> IMO your patch is missing the only point I agree with you on this issue= , i.e., >> >> So you don't agree that it's a good idea to warn about non-portable code? > > Wel, as you might guess I don=E2=80=99t like warnings in general: too muc= h false positives > and missed targets (see recent bootstrap breakage). So then: Do you have a better solution for the problem at hand? The cleaner approach would certainly be to avoid short-circuiting of impure functions altogether. If we can all agree that this is a good idea, I'll be happy to submit a patch in that direction. But recent discussions have shown that there is a broad opposition of hardliners who favor optimization to portability. I don't really have the nerves and the time to continue this endless fight, so for now I would be satisfied if we at least had the warnings. >>> What to do with >>> >>> if(x>0 .and. sort(x)<10.0*log(x)) =E2=80=A6 >>> >>> which is not portable to compilers computing the two expressions? >> >> That's one of the typical cases that the patch should be able to >> handle. If 'sort' is impure, this should trigger a warning with the >> patch. If it is pure, it doesn't matter whether the rhs of the .and. >> operator is executed (since there are no side effects). Or am I >> missing something? > > I meant =E2=80=98sqrt=E2=80=99 (changed behind my back by the stupid spel= l-checker). sqrt and log are both elemental, thus pure, so there will be no warning. Cheers, Janus