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 in many cases. (See guideline recommendation [MSC00-C. Compile cleanly at high warning levels.)
...
If the intent was to increment the value referred to by p
, then parentheses can be used to ensure p
is dereferenced and then incremented. (See guideline recommendation EXP00-C. Use parentheses for precedence of operation.)
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
CERT C++ Secure Coding Standard: MSC12-CPP. Detect and remove code that has no effect
The CERT Oracle Secure Coding Standard for Java: MSC17-J. Detect and remove dead code
ISO/IEC TR 24772: "BRS Leveraging human experience," "BVQ Unspecified Functionality," "KOA Likely incorrect expressions," and "XYQ Dead and Deactivated Code"
MISRA C 2004: Rule 14.1 and Rule 14.2
Bibliography
...