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).
For a related recommendation, please see \[[This recommendation is related to MSC07-A. Detect and remove dead code]\]. Wiki Markup
Non-Compliant Code Example (assignment)
...
Code Block | ||
---|---|---|
| ||
int *p; /* ... */ p++; |
If the intent was to increment the value referred to by {{ Wiki Markup 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 | ||
---|---|---|
| ||
int *p; /* ... */ (*p)++ |
...