V1021. The variable is assigned the same value on several loop iterations.

The analyzer has detected a loop with a suspicious assignment operation, which could make that loop infinite.

Consider the following example:

static void f(Node *n)
{
  for (Node *it = n; it != nullptr; it = n->next)
  ....
}

This is a typical construct used to traverse lists. When 'n' is not modified, this loop will either never iterate or will iterate infinitely.

Fixed code:

static void f(Node *n)
{
  for (Node *it = n; it != nullptr; it = it->next)
  ....
}

According to Common Weakness Enumeration, potential errors found by using this diagnostic are classified as CWE-835.


Bugs Found

Checked Projects
410
Collected Errors
14 111
This website uses cookies and other technology to provide you a more personalized experience. By continuing the view of our web-pages you accept the terms of using these files. If you don't want your personal data to be processed, please, leave this site. Learn More →
Accept