-Wparentheses lumps too much together

2007-12-19 Thread jklowden
Hello Gentlemen, Much as I'm a fan of the GCC and rely on -Wall, I would like to suggest to you that -Wparentheses should be split up, and things it checks/suggests be moved out of -Wall. If this is not the right forum or if you'd rather see this as a bug report, I'm happy to go where I'm point

Re: -Wparentheses lumps too much together

2007-12-19 Thread Doug Gregor
On Dec 19, 2007 3:02 PM, <[EMAIL PROTECTED]> wrote: > One last point. In looking for the rationale behind this warning, I searched > for examples of it. I didn't find any discussion on this list. What I did > find were many examples of people rototilling perfectly fine code, "improving" > it by

Re: -Wparentheses lumps too much together

2007-12-19 Thread Daniel Jacobowitz
On Wed, Dec 19, 2007 at 03:02:35PM -0500, [EMAIL PROTECTED] wrote: > My specific candidate for exclusion from -Wall is this one: > > if (a && b || c && d) > > which yields (as you know) advice to parenthesize the two && pairs. > > I very much think this is unhelpful, counterproductive ad

Re: -Wparentheses lumps too much together

2007-12-19 Thread Ismail Dönmez
Wednesday 19 December 2007 22:11:22 tarihinde Doug Gregor şunları yazmıştı: > On Dec 19, 2007 3:02 PM, <[EMAIL PROTECTED]> wrote: > > One last point. In looking for the rationale behind this warning, I > > searched for examples of it. I didn't find any discussion on this list. > > What I did fi

Re: -Wparentheses lumps too much together

2007-12-19 Thread Ian Lance Taylor
[EMAIL PROTECTED] writes: > Much as I'm a fan of the GCC and rely on -Wall, I would like to suggest > to you that -Wparentheses should be split up, and things it checks/suggests > be moved out of -Wall. If this is not the right forum or if you'd rather > see this as a bug report, I'm happy to go

Re: -Wparentheses lumps too much together

2007-12-19 Thread James K. Lowden
Ian Lance Taylor wrote: > I have no objection to splitting -Wparentheses into separate warnings > controlled by separate options. Thank you, Ian. > > which yields (as you know) advice to parenthesize the two && pairs. > > That particular warning happened to find dozens of real errors when I

Re: -Wparentheses lumps too much together

2007-12-20 Thread Paul Brook
> My untested (and consequently firmly > held) hypothesis is that > > 1) most combinations of && and || don't need parentheses because > > (a && b) || (c && d) > > is by far more common than > > a && (b || c) && d > > and, moreover, broken code fails at runtime, and I dispute these cla

Re: -Wparentheses lumps too much together

2007-12-20 Thread Ian Lance Taylor
"James K. Lowden" <[EMAIL PROTECTED]> writes: > > That particular warning happened to find dozens of real errors when I > > ran it over a large code base. It may be noise for you, but I know > > from personal experience that it is very useful. > > I would like to hear more about that, if you wou

Re: -Wparentheses lumps too much together

2007-12-20 Thread James K. Lowden
Ian Lance Taylor wrote: > A typical true positive looked more or less like > > if (a && > b || c) http://www.jetcafe.org/jim/c-style.html It's funny you should mention that. A warning about whitespace indentation that's inconsistent with the expressed logic *would* be helpful (and c

Re: -Wparentheses lumps too much together

2007-12-21 Thread Ralf Wildenhues
freetds.org> writes: > > Yes, I know beginners get confused by and/or precedence. But > *every* language that I know of that has operator precedence places > 'and' before 'or'. FWIW, Bourne shell doesn't, && and || have equal precedence there. That's a bit off-topic though, as it's not an argu

Re: -Wparentheses lumps too much together

2007-12-21 Thread NightStrike
On 12/20/07, Ralf Wildenhues <[EMAIL PROTECTED]> wrote: > freetds.org> writes: > > > > Yes, I know beginners get confused by and/or precedence. But > > *every* language that I know of that has operator precedence places > > 'and' before 'or'. > > FWIW, Bourne shell doesn't, && and || have equal

Re: -Wparentheses lumps too much together

2007-12-21 Thread Ross Smith
Paul Brook wrote: >James K. Lowden wrote: 1) most combinations of && and || don't need parentheses because (a && b) || (c && d) is by far more common than a && (b || c) && d and, moreover, broken code fails at runtime, and I dispute these claims. The former may be statisti

Re: -Wparentheses lumps too much together

2008-01-10 Thread Rehno Lindeque
> > Yes, I know beginners get confused by and/or precedence. But > > *every* language that I know of that has operator precedence places > > 'and' before 'or'. > > FWIW, Bourne shell doesn't, && and || have equal precedence there. > That's a bit off-topic though, as it's not an argument against yo

Re: -Wparentheses lumps too much together

2008-01-11 Thread Robert Dewar
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 nota

Re: -Wparentheses lumps too much together

2008-01-11 Thread Joe Buck
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. Howe

Re: -Wparentheses lumps too much together

2008-01-11 Thread Doug Gregor
On Dec 19, 2007 3:02 PM, <[EMAIL PROTECTED]> wrote: > My specific candidate for exclusion from -Wall is this one: > > if (a && b || c && d) > > which yields (as you know) advice to parenthesize the two && pairs. To make this discussion a bit more concrete, the attached patch removes this

Re: -Wparentheses lumps too much together

2008-01-11 Thread Ian Lance Taylor
Joe Buck <[EMAIL PROTECTED]> writes: > 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. That is what -

Re: -Wparentheses lumps too much together

2008-01-11 Thread Joe Buck
On Fri, Jan 11, 2008 at 03:24:46PM -0800, Ian Lance Taylor wrote: > Joe Buck <[EMAIL PROTECTED]> writes: > > > 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 o

Re: -Wparentheses lumps too much together

2008-01-11 Thread Ian Lance Taylor
"Doug Gregor" <[EMAIL PROTECTED]> writes: > To make this discussion a bit more concrete, the attached patch > removes this particular warning from -Wparentheses and puts it into a > new warning, -Wprecedence, that is not enabled by -Wall. This is > slightly more fine-grained than what -Wparenthese

Re: -Wparentheses lumps too much together

2008-01-12 Thread Andreas Schwab
Ian Lance Taylor <[EMAIL PROTECTED]> writes: > I'm inclined to approve this if -Wprecedence stays in -Wall, but I'd > like to hear if anybody else has anything to say. The name of the option is rather poor, IMHO. -Wparentheses warns about precedences, so what is the difference to -Wprecedence?

Re: -Wparentheses lumps too much together

2008-01-12 Thread Paolo Bonzini
Andreas Schwab wrote: Ian Lance Taylor <[EMAIL PROTECTED]> writes: I'm inclined to approve this if -Wprecedence stays in -Wall, but I'd like to hear if anybody else has anything to say. The name of the option is rather poor, IMHO. -Wparentheses warns about precedences, so what is the differe

Re: -Wparentheses lumps too much together

2008-01-13 Thread Gabriel Dos Reis
Ian Lance Taylor <[EMAIL PROTECTED]> writes: | "Doug Gregor" <[EMAIL PROTECTED]> writes: | | > To make this discussion a bit more concrete, the attached patch | > removes this particular warning from -Wparentheses and puts it into a | > new warning, -Wprecedence, that is not enabled by -Wall. Thi

Re: -Wparentheses lumps too much together

2008-03-10 Thread Derek M Jones
All, Developer knowledge of operator precedence and the issue of what they intended to write are interesting topics. Some experimental work is described in (binary operators only I'm afraid): www.knosof.co.uk/cbook/accu06a.pdf www.knosof.co.uk/cbook/accu07a.pdf The ACCU 2006 experiment provide