Our website uses cookies to enhance your browsing experience.
Accept
to the top
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I am interested to try it on the platforms:
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam

Webinar: Parsing C++ - 10.10

>
>
>
V6024. The 'continue' operator will ter…
menu mobile close menu
Analyzer diagnostics
General Analysis (C++)
General Analysis (C#)
General Analysis (Java)
Micro-Optimizations (C++)
Diagnosis of 64-bit errors (Viva64, C++)
Customer specific requests (C++)
MISRA errors
AUTOSAR errors
OWASP errors (C#)
Problems related to code analyzer
Additional information
toggle menu Contents

V6024. The 'continue' operator will terminate 'do { ... } while (false)' loop because the condition is always false.

May 07 2018

The analyzer detected a code fragment that may mislead programmers reading it. Not all developers know that using the "continue" statement in a "do { ... } while(false)" loop will terminate it instead of continuing its execution.

So, after executing the 'continue' statement, the '(false)' condition will be checked and the loop will terminate because the condition is false.

Consider the following example:

int i = 1;
do
{
  System.out.print(i);
  i++;
  if (i < 3)
    continue; 
  System.out.print('A');
} while (false);

The programmer may expect the program to print '12A', but it will actually print '1'.

Even if the code was intended to work that way and there is no error, it is still recommended to revise it. For example, you can use the 'break' statement:

int i = 1;
do
{
  System.out.print(i);
  i++;
  if (i < 3)
    break; 
  System.out.print('A');
} while (false);

The code has become clearer; one can immediately see that the loop will terminate if the "(i < 3)" condition is true. In addition, it won't trigger the analyzer warning anymore.

If the code is incorrect, it must be fixed. There are no set rules as to how exactly it should be rewritten since it depends on the code's execution logic. For example, if you need the program to print '12A', it is better to rewrite this fragment as follows:

for (int i = 1; i < 3; ++i)
  System.out.print(i);
System.out.print('A');

This diagnostic is classified as: