Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
bgColor#FFcccc
int a = 2;
int b = 2;
int c = 2;
//* ... */
if (a < b < c) /* misleading, likely bug */
//* ... */
if (a == b == c) /* misleading, likely bug */

...

Code Block
bgColor#ccccff
if ( (a < b) && (b < c) ) /* clearer, and probably what was intended */
//* ... */
if ( (a == b) && (a == c) ) /* ditto */

Automated Detection

The gcc GCC option -Wparentheses warns if a comparison like `x<x<=y<=z' appears. This warning is also enabled by -Wall.

...