Versions Compared

Key

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

Code that is executed but does not perform any action, or has an unintended effect, most likely results from a coding error and can result in unexpected behavior. Statements or expressions that have no effect should be identified and removed from code. Most modern compilers can warn about code that has no effect (see MSC00-A. Compile cleanly at high warning levels).

Wiki MarkupFor a related recommendation, please see \[[This recommendation is related to MSC07-A. Detect and remove dead code]\].

Non-Compliant Code Example (assignment)

...

Code Block
bgColor#ccccff
int *p;
/* ... */
p++;

Wiki MarkupIf the intent was to increment the value referred to by {{p}}, then parentheses can be used to ensure {{p}} is dereferenced then incremented \[[incremented (see EXP00-A. Use parentheses for precedence of operation]\]).

Code Block
bgColor#ccccff
int *p;
/* ... */
(*p)++

...