>
>
>
V6037. An unconditional 'break/continue…


V6037. An unconditional 'break/continue/return/goto' within a loop.

The analyzer has detected a suspicious loop where one of the following statements is used: continue, break, return, goto, or throw. These statements are executed all the time, irrespective of any conditions.

For example:

for(int k = 0; k < max; k++)
{
  if (k == index)
    value = Calculate(k);
  break; 
}

In this code, the 'break' statement doesn't belong to the 'if' statement, which will cause it to execute all the time, regardless of whether or not the 'k == index' condition is true, and the loop body will iterate only once. The correct version of this code should look like this:

for(int k = 0; k < max; k++)
{
  if (k == index)
  {
    value = Calculate(k);
    break;
  }
}

This diagnostic is classified as:

You can look at examples of errors detected by the V6037 diagnostic.