Examples of errors detected by the V533 diagnostic.


V533. It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'X'.


Doom 3

V533 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'j'. idLib surface_polytope.cpp 65


void idSurface_Polytope::FromPlanes(....)
{
  ...
  for ( j = 0; j < w.GetNumPoints(); j++ ) {
    for ( k = 0; k < verts.Num(); j++ ) {
      if ( verts[k].xyz.Compare(w[j].ToVec3(),
                                POLYTOPE_VERTEX_EPSILON ) ) {
        break;
      }
    }
    ...
  }
  ...
}

This is what should have been written here: for ( k = 0; k < verts.Num(); k++ ).


Simple DirectMedia Layer

V533 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'i'. testshape testshape.c 130


int main(int argc,char** argv)
{
  ....
  for(i=0;i<num_pictures;i++) {
    pictures[i].texture = SDL_CreateTextureFromSurface(....);
    if(pictures[i].texture == NULL) {
      j = 0;
      for(j=0;j<num_pictures;i++)                      // <=
        if(pictures[i].texture != NULL)
          SDL_DestroyTexture(pictures[i].texture);
      for(i=0;i<num_pictures;i++)
        SDL_FreeSurface(pictures[i].surface);
      ....
    }
  }
  ....
}

Godot Engine

V533 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'i'. scene_preloader.cpp 410


Dictionary ScenePreloader::_get_bundled_scene() const
{
  ....
  Vector<int> rconns;
  ....
  for(int i=0;i<connections.size();i++)
  {
    ....
    for(int j=0;j<cd.binds.size();i++)
      rconns.push_back(cd.binds[j]);
  }
  ....
}

Unreal Engine 4

V533 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'LineIdx'. internationalizationexportcommandlet.cpp 661


bool FPortableObjectFormatDOM::FromString( const FString& InStr )
{
  ....
  for( uint32 NextLineIdx = LineIdx + 1;    // <=
       NextLineIdx < NumFileLines &&
       LinesToProcess[NextLineIdx].Trim().TrimTrailing()....;
       ++LineIdx )                          // <=
  {
    ....
  }
  ....
}

This is what should have been written here: ++NextLineIdx.


Open X-Ray Engine

V533 It is likely that a wrong variable is being incremented inside the 'for' operator. Consider reviewing 'i'. mxqmetric.cpp 76


MxMatrix& MxQuadric::homogeneous(MxMatrix& H) const
{
  ....
  unsigned int i, j;

  for(i=0; i<A.dim(); i++)  for(j=0; j<A.dim(); i++)
    H(i,j) = A(i,j);
  ....
}


Do you make errors in the code?

Check your code
with PVS-Studio

Static code analysis
for C, C++, and C#

goto PVS-Studio;