Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rule 4-5-1 prohibits 'b1 |= b2;' ?
#2
grunwald Wrote:Neither `|` nor `|=` is listed as allowed operator.
Does this mean the following code a violation of Rule 4-5-1?

Code:
bool b1 = false;

void f(int x)
{
    b1 |= (x == 0);
}
x |= y is just short for x = x | y and bitwise operators are forbidden by the rationale in this rule.
Code:
FlexeLint for C/C++ (Unix) Vers. 9.00L, Copyright Gimpel Software 1985-2014
--- Module: diy.cpp (C++)
     1  //lint -indirect(au-misra-cpp-alt.lnt) -e514 -e1786 -e9141 -e970 -e952
     2  bool b1 = false;
     3  
     4  void f(int x)
     5  {
                          _
     6      b1 |= (x == 0);
diy.cpp  6  Note 9111:  boolean expression used with non-permitted operator ''|'' [MISRA C++ Rule 4-5-1]
diy.cpp  6  Note 9111:  boolean expression used with non-permitted operator ''|'' [MISRA C++ Rule 4-5-1]
<t></t>
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 3 Guest(s)