MISRA Discussion Forums
Rule 6-6-3 in while-loops - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C++ (https://forum.misra.org.uk/forumdisplay.php?fid=18)
+--- Forum: MISRA C++:2008 rules (https://forum.misra.org.uk/forumdisplay.php?fid=19)
+---- Forum: 6.6 Statements (C++) (https://forum.misra.org.uk/forumdisplay.php?fid=135)
+---- Thread: Rule 6-6-3 in while-loops (/showthread.php?tid=1514)



Rule 6-6-3 in while-loops - jungsun.goh - 29-10-2019

Dear MISRA members,

Regarding the rule 6-6-3:
Does this rule only apply to for-loops or does it also apply to while-loops?

For references, the static analysis tool, Coverity reports a 6-6-3 rule violation when 'continue' statement is used in a while-loop.

Best Regards,
Goh


Re: Rule 6-6-3 in while-loops - misra cpp - 22-01-2020

As formulated, this statement prevents the use of continue in while loops.

However, there have been a number of previous posts about whether rules 6-5-1 to 6-5-6 apply to while loops as well as for loops. The reply to “Rules 6-5-1 to 6-5-6” by dg1980 April 28 2016 (in section 6.5 of the bulletin board) was:

6-5-1 only applies to for loops, arguably 6-5-2 to 6-5-6 may apply to while loops as well.

These rules are under consideration in light of this and MISRA C:2012's approach

This applies to 6-6-3 as well