10-03-2010, 11:08 AM
The concept of the "effectively Boolean" type is discussed in MISRA-C:2004 Appendix E.
According to this concept, there is no need to use an intermediate variable of type int to hold the result of a Boolean, equality or relational operator. Your example:
could therefore be written as:
This is permitted according to MISRA-C:2004 Rule 12.6 as amended by Technical Corrigendum 1. It was not permitted according to the original MISRA-C:2004. It may therefore be the case that your checking tool has not incorporated TC1. Your results will also depend on how your checking tool identifies the effectively Boolean type.
According to this concept, there is no need to use an intermediate variable of type int to hold the result of a Boolean, equality or relational operator. Your example:
Code:
int _t = c && d;
boolU8 = (uint8)_t;
could therefore be written as:
Code:
boolU8 = c && d;
This is permitted according to MISRA-C:2004 Rule 12.6 as amended by Technical Corrigendum 1. It was not permitted according to the original MISRA-C:2004. It may therefore be the case that your checking tool has not incorporated TC1. Your results will also depend on how your checking tool identifies the effectively Boolean type.
Posted by and on behalf of the MISRA C Working Group