Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why example in Rule A5-0-2 is non-complient
#2
The example above the line you quote, "if (u8)", is non-compliant because u8 is not of type bool. The rationale is that it is unclear whether the programmer recognises that (u8) is equivalent to (u8 != 0) or whether some other condition has been omitted.

The example you quote is there to illustrate that 'u8' doesn't become an acceptable Boolean value when incorporated into a more complex expression. It is arguable that the condition isn’t non-compliant with A5-0-2, as the type of the logical && expression is bool. However, It is non-compliant with M5-3-1 “Each operand of the ! operator, the logical && or logical || operators shall have the type bool”. The comment ought to say ‘compliant with this rule, but non-compliant with M5-3-1’.
Posted by and on behalf of
the MISRA C++ Working Group
Reply


Messages In This Thread
RE: Why example in Rule A5-0-2 is non-complient - by misra cpp - 05-08-2022, 11:37 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)