MISRA Discussion Forums

Full Version: 14.3 and do-while within logical-and operator
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Would the following example be compliant with rule #14.3?
Code:
do {
     // code..
} while ( (s8a < 10) && (s8a > 20) );  /* is && operator an essentially boolean controlling expression ? */
The controlling expression of the while loop in the above example is "(s8a < 10) && (s8a > 20)". This expression will evaluate to False for all values of s8a. Therefore this is non-compliant with the rule 14.3.
Quote:The controlling expression of the while loop in the above example is "(s8a < 10) && (s8a > 20)". This expression will evaluate to False for all values of s8a. Therefore this is non-compliant with the rule 14.3.
Isn't it target by exception 2 ?
I agree - it's compliant by virtue of exception 2 isn't it? I can't see how it's any different from this example given under Rule 14.3:

Code:
do {
  /* Compliant by exception 2 */
} while ( 0u == 1u );
The MISRA-C group apologise for the incorrect response first given to this question. The above posters are correct in saying the example meets the requirements of exception 2 and is therefore compliant with rule 14.3.