MISRA Discussion Forums

Full Version: Rule 15.3 Example
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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/
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.