`RULE-10-4`: False negatives as rule does not currently consider ternaries
MichaelRFairhurst opened this issue · 0 comments
MichaelRFairhurst commented
Affected rules
RULE-10-4
Description
The text states that the rule applies to usual arithmetic conversions, and the c spec states that for a ? b : c the usual arithmetic conversions are performed on operands b and c. However, OperationWithUsualArithmeticConversions from MisraExpressions.qll holds for this instanceof BinaryOperation and ... or this instanceof AssignArithmeticOperation, it should also hold for this instanceof ConditionalExpr and getLeftOperand() / getRightOperand() should return operands 2 & 3.
Example
void example_function() {
int x;
float y;
bool b;
b ? x : y; // FALSE NEGATIVE
}