MISRA Discussion Forums
Rule 15.3 Example - Printable Version

+- MISRA Discussion Forums (https://forum.misra.org.uk)
+-- Forum: MISRA C (https://forum.misra.org.uk/forumdisplay.php?fid=4)
+--- Forum: MISRA C:2012 and MISRA C:2023 guidelines (https://forum.misra.org.uk/forumdisplay.php?fid=21)
+---- Forum: 8.15 Control flow (https://forum.misra.org.uk/forumdisplay.php?fid=170)
+---- Thread: Rule 15.3 Example (/showthread.php?tid=1021)



Rule 15.3 Example - ogawa.kiyoshi - 21-01-2014

Rule 15.3 Example
void f1(int32_t a){
if ( a 0){
L2:
;
}
}
has some unreachable codes. So I think
void f1(int32_t a){
if ( a 0){
L2:
;
}
}
are enough and no unreachable codes.

Dr. Ogawa Kiyoshi
https://twitter.com/kaizen_nagoya/, http://researchmap.jp/kaizen/MISRA-C/


Re: Rule 15.3 Example - misra-c - 03-02-2014

Thank you for your comment. The examples in the guidelines have be written with an attempt to minimise violations with other guidelines. However, in some examples other guidelines are violated in order to keep the example concise.

In this example the first "goto L1;" demonstrates that a jump to the same level of block is compliant. In hindsight it might have been clearer to have had another label "L3" to have demonstrated this point.