Versions Compared

Key

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

...

While this noncompliant code example compiles correctly, it is unlikely that it means what the author of the code intended.

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

...

Treat relational and equality operators as if it were invalid to chain them.

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

...