Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RULE-10-4: False negatives as rule does not currently consider ternaries #821

Open
MichaelRFairhurst opened this issue Dec 12, 2024 · 0 comments
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address false positive/false negative An issue related to observed false positives or false negatives. false-negative An issue representing a false negative report. Impact-Low Standard-MISRA-C

Comments

@MichaelRFairhurst
Copy link
Contributor

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
}
@MichaelRFairhurst MichaelRFairhurst added Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address false positive/false negative An issue related to observed false positives or false negatives. false-negative An issue representing a false negative report. Impact-Low Standard-MISRA-C labels Dec 12, 2024
@MichaelRFairhurst MichaelRFairhurst changed the title RULE-10-4: Rule does not consider ternaries RULE-10-4: False negatives as rule does not currently consider ternaries Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Difficulty-Low A false positive or false negative report which is expected to take <1 day effort to address false positive/false negative An issue related to observed false positives or false negatives. false-negative An issue representing a false negative report. Impact-Low Standard-MISRA-C
Projects
None yet
Development

No branches or pull requests

1 participant