SFS -- Suspicious For Statement

From RAD Studio
Jump to: navigation, search

Go Up to C++ Audits

Description

SFS checks for iterator variable usage. It tries to detect a situation where different variables are used in initialization, condition, and the increment part of a for loop. Most likely, it means that the wrong variable is used.

Incorrect

 for (int i = 0; i < lengthX; i++) { 
   for (int j = 0; j < lengthY; i++) {
      ...
   }
 }

Correct

 for (int i = 0; i < lengthX; i++) { 
   for (int j = 0; j < lengthY; j++) { 
     ...
   }
 }

See Also