Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
14.3 and do-while within logical-and operator
#1
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 ? */
<t></t>
#2
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.
Posted by and on behalf of the MISRA C Working Group
#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 ?
<t></t>
#4
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 );
<t></t>
#5
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.
Posted by and on behalf of the MISRA C Working Group


Forum Jump:


Users browsing this thread: 2 Guest(s)