why( warning: left-hand operand of comma expression has no effect)

Jonathan Neuschäfer j.neuschaefer at gmx.net
Sun Nov 25 12:39:39 CET 2012


On Sat, Nov 24, 2012 at 06:50:53PM -0800, Colin McCabe wrote:
> I do think it would make sense to replace that:
> assert("foo was 0", foo) ;
assert(("foo was 0", foo)); /* mind the parentheses */
> with:
> assert("foo was 0" && foo);
> 
> The latter doesn't produce any gcc warnings for me, whereas the former
> does.  But at the end of the day, that's up to the maintainer... he's
> the one who has to sift through the compilation warnings.

Until someone comes up with a "string literals always evaluate to true
in boolean expressions" warning. Cppcheck (a static analyzer for C,
C++ and a few other languages) has such a warning.

HTH,
Jonathan Neuschäfer



More information about the libev mailing list