Versions Compared

Key

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

MSCXX-A. Detect and remove code that has no effect

Code that does not perform any action, or has an unintended effect can result in unexpected behavior and vulnerabilities. Statements or expressions that have no effect should be identified and removed from code.

...

Code Block
bgColor#FFCCCC
int a;
a == b;
/* ... */      

This is likely a case of the programmer mistakenly using the equals operator == instead of the assignment operator =.

...

Code Block
bgColor#ccccff
int a;
a = b;
/* ... */      

Non-Compliant Code Example 2

...

Code Block
bgColor#FFCCCC
int *p;
*p++;             

Compliant Solution 2

Dereferencing p has no effect and should not be dereferenced.

...