This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: -Wparentheses lumps too much together


On Wed, Dec 19, 2007 at 03:02:35PM -0500, jklowden@freetds.org 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 advice.
> 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'.  More important, a C programmer will encounter
> many thousands such expressions in his dealings with the language.
> To "help" him is merely to retard his education.

I am happy to stand as a counterexample; I am an experienced C
programmer and I greatly appreciate this warning.  And I loathe
reading code which cavalierly assumes you remember the precedence.  +
and *, sure, you learn that in grade school.  && and || is trickier
because there are sensible arguments for both directions; it is
harder to derive from first principles.

If you are more bothered by any clarifying parentheses than I am,
use -Wno-parentheses.

-- 
Daniel Jacobowitz
CodeSourcery


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]