From: Robert Dewar <dewar@adacore.com>
To: Joe Buck <Joe.Buck@synopsys.COM>
Cc: Rehno Lindeque <errantkid@gmail.com>,
Ross Smith <r-smith@ihug.co.nz>,
gcc@gcc.gnu.org
Subject: Re: -Wparentheses lumps too much together
Date: Fri, 11 Jan 2008 17:05:00 -0000 [thread overview]
Message-ID: <4787A188.2000909@adacore.com> (raw)
In-Reply-To: <20080111165936.GB31668@synopsys.com>
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.
next prev parent reply other threads:[~2008-01-11 17:05 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-12-19 20:07 jklowden
2007-12-19 20:14 ` Doug Gregor
2007-12-19 20:39 ` Ismail Dönmez
2007-12-19 20:15 ` Daniel Jacobowitz
2007-12-19 23:11 ` Ian Lance Taylor
2007-12-20 6:08 ` James K. Lowden
2007-12-20 16:41 ` Paul Brook
2007-12-21 20:19 ` Ross Smith
2008-01-11 7:34 ` Rehno Lindeque
2008-01-11 17:00 ` Joe Buck
2008-01-11 17:05 ` Robert Dewar [this message]
2008-01-11 23:26 ` Ian Lance Taylor
2008-01-12 0:50 ` Joe Buck
2007-12-20 18:01 ` Ian Lance Taylor
2007-12-21 5:28 ` James K. Lowden
2007-12-21 9:27 ` Ralf Wildenhues
2007-12-21 17:16 ` NightStrike
2008-01-11 22:44 ` Doug Gregor
2008-01-12 3:48 ` Ian Lance Taylor
2008-01-12 10:16 ` Andreas Schwab
2008-01-12 11:23 ` Paolo Bonzini
2008-01-13 16:03 ` Gabriel Dos Reis
2008-03-10 17:25 Derek M Jones
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4787A188.2000909@adacore.com \
--to=dewar@adacore.com \
--cc=Joe.Buck@synopsys.COM \
--cc=errantkid@gmail.com \
--cc=gcc@gcc.gnu.org \
--cc=r-smith@ihug.co.nz \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).