Do statements should not be used
Do statements should not be used.
A do statement can introduce bugs in your code because its
termination condition is checked after executing the code block. Consider this code where an
array is accessed by using a pointer in a do-while
loop.
int* array;
//...
do {
cout<<*array;
--array;
} while (array != nullptr); Avoid do statements in your code. You can use do
statements to write function-like macros.
Polyspace® flags all do statements, except those located in
macros.
If you expect a rule violation but do not see it, refer to Coding Standard Violations Not Displayed.
| Group: Statements |
| Category: Advisory, Automated |