[cfe-dev] [PATCH] -Wconversion-null

James K. Lowden jklowden at schemamania.org
Sat Mar 17 11:50:12 PDT 2012


On Thu, 15 Mar 2012 21:31:39 -0500
Joshua Cranmer <pidgeot18 at gmail.com> wrote:

> I should be 
> able to look at code and not have to reason about the formal
> underlying algebraic model to figure out what the intent is

You don't really mean that, do you?  What is programming except the use
of logical constructs, and how is it possible to program in any
language without know the meaning expressed through its syntax?  

Regarding bit-wise operators, I didn't make that case.  They're
relatively rarely used, and even Dennis Ritchie expressed some regret
over their precedence.  Logical operators, on the other hand, appear in
all but the most trivial programs. 

> most people don't memorize the precedence charts and instantly 
> plan for minimizing parenthesis usage, especially when you consider
> that precedence does vary between languages

I'm not prepared to make any claim about what most programmers do or
think.  I have a hard time believing, per above, that much useful work
can be accomplished in C++ without knowing the precedence of C++
operators.  

If you know a language that 1) defines operator precedence and 2)
defines OR before AND, I'd be interested to hear.  I was unable to find
one.  For that reason I reject the "multi-language confusion"
hypothesis.  

AFAIK the question of bugs stemming from logical operator confusion
hasn't been carefully studied. Rather than assume I'm smarter than the
poor schlump using my compiler, I prefer to think that whatever I know,
anyone else can learn, too.

Note you're positing a very peculiar kind of ignorance: the
programmer who isn't sure of the precedence *and* decides not to use
parentheses to make the logic clear to *himself*.  I would not presume
to try to help such a person, and I don't think Clang should, either.  

--jkl



More information about the cfe-dev mailing list