From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30037 invoked by alias); 11 Jan 2008 17:05:02 -0000 Received: (qmail 30018 invoked by uid 22791); 11 Jan 2008 17:05:01 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 11 Jan 2008 17:04:41 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id B92F92A96BF; Fri, 11 Jan 2008 12:04:39 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Jp1j9-uAb-a2; Fri, 11 Jan 2008 12:04:39 -0500 (EST) Received: from [127.0.0.1] (nile.gnat.com [205.232.38.5]) by rock.gnat.com (Postfix) with ESMTP id 86A0D2A967E; Fri, 11 Jan 2008 12:04:39 -0500 (EST) Message-ID: <4787A188.2000909@adacore.com> Date: Fri, 11 Jan 2008 17:05:00 -0000 From: Robert Dewar User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Joe Buck CC: Rehno Lindeque , Ross Smith , gcc@gcc.gnu.org Subject: Re: -Wparentheses lumps too much together References: <20071219200235.GA21525@oak.schemamania.org> <20071220005030.4971a442.jklowden@freetds.org> <200712201509.20582.paul@codesourcery.com> <476C1461.2050107@ihug.co.nz> <20080111165936.GB31668@synopsys.com> In-Reply-To: <20080111165936.GB31668@synopsys.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2008-01/txt/msg00142.txt.bz2 Joe Buck wrote: > On Fri, Jan 11, 2008 at 09:34:29AM +0200, Rehno Lindeque wrote: >> Just a note: Operator precedence is taught as logical AND comes before >> OR in logic courses. So it is a sort of a standard mathematical >> convention just like + and *. In fact, OR is even represented as a + >> in some notations. However it might not be practical to assume all >> programmers have a background in logic. > > A warning that flagged code like > > if (c1 || c2 && c3) > ... > > would swamp users in warnings, since this kind of code is extremely > common, and this isn't the kind of thing that anyone who's not a total C > beginner has trouble with. I find it a valuable warning, I think it is a mistake to rely on dubious precedence for cases like this (dubious because the analogy of || and && with + and * is stretching things). I must say I prefer the Ada syntax here, which prohibits mixing of different logical operators in this way.