Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Example for rule 10.1
#1
as per the misra-c writtent in one of its reply that -
Rules 10.1 and 10.3 were designed with signed and unsigned expressions in mind. The treatment of enums, bitfields, chars, relational operators ( < , , >= ), logical operators ( &&, || ) and equality operators ( ==, != ) do not fit this model as yet.

But in Exempler test file mc2_1001.c line number 221
if ( u16r == 1 ) /* Not Compliant */

So if == operator do not fit in the 10.1 model then Why this line is Not Cpmpliant?
<t></t>
Reply
#2
It is true that MISRA Rule 10.1 does not address the issue of underlying type except in the context of signed and unsigned types. The reply that you have quoted refers to the result of relational, equality and logical operations so it is important to remember that Rule 10.1 may still apply to the operands of these operators.

A future version of MISRA-C will extend the concept of underlying type so that, for example, the result of a relational, logical or equality operator (an "effectively Boolean" expression), would be considered to have a 'Boolean' underlying type.

However this does not in any way conflict with the principle enshrined in Rule 10.1 that implicit conversions shall not take place between signed and unsigned types. The operands of a binary operand in which the "usual arithmetic conversions" apply, must therefore be of the same underlying signedness. So the expression "(u16r == 1)" is not compliant , whereas "(u16r == 1u)" would be compliant.
Posted by and on behalf of the MISRA C Working Group
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)