Affected rules
- RULE-7-0-4 ( cpp/misra/inappropriate-bitwise-or-shift-operands )
Description
InappropriateBitwiseOrShiftOperands.ql reports operations that do not use the built-in bitwise or shift operators. The overwhelming majority of these are uses of the stream insertion and extraction operators, e.g. stream << value .
On our codebase ( eclipse-score/communication ) this accounts for 72 of 76 reported violations, i.e. ~95% of the results for this rule are false positives.
Typical messages:
Shift operator '<<' requires unsigned left operand, but has type 'basic_ostream<char, char_traits<char>> &'.
Shift operator '<<' requires unsigned left operand, but has type 'unknown'.
Shift operator '<<' requires unsigned right operand, but has type 'auto &&'.
Shift operator '<<' requires unsigned right operand, but has type 'const char[22]'.
Example
template<typename ServiceIdType>
std::string ToHexString(const ServiceIdType service_id) {
std::stringstream stream;
// FALSE POSITIVE: reported twice, for the left and the right operand
stream << std::setfill('0') << std::setw(8) << std::hex << service_id;
return stream.str();
}
Affected rules
Description
InappropriateBitwiseOrShiftOperands.ql reports operations that do not use the built-in bitwise or shift operators. The overwhelming majority of these are uses of the stream insertion and extraction operators, e.g. stream << value .
On our codebase ( eclipse-score/communication ) this accounts for 72 of 76 reported violations, i.e. ~95% of the results for this rule are false positives.
Typical messages:
Example