Skip to content

A7-5-2, RULE-8-2-10: callers of recursive functions reported as recursive #935

@MichaelRFairhurst

Description

@MichaelRFairhurst

Affected rules

  • A7-5-2
  • RULE-8-2-10

Description

The query finds RecursiveCall rcs and then reports FunctionCall fcs where fc.getTarget() = rc.getTarget(). This means call sites of recursive functions are treated as recursive.

Recursion is something we should expect to be deviated. This bug imposes additional burden on developers to deviate at all callsites of functions that have been deemed safe recursion.

Discussion: is this bug a feature? Sometimes evaluating the safety of a recursive call depends on the entry point arguments. For instance, counting the length of a linked list is safe if the linked list has no cycles, which should be a check that precedes the recursive call.

Example

If we add these new lines to the test.cpp file:

int test_calls_recursive_function(int i) {
  test_recursive_function(i); // COMPLIANT
}

We incorrectly get a result claiming that test_calls_recursive_function is recursive. This is incorrect and unnecessary, since test_recursive_function is already flagged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressImpact-LowStandard-AUTOSARStardard-MISRA-C++false positive/false negativeAn issue related to observed false positives or false negatives.false-positiveAn issue representing a false positive report.

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions