-
Notifications
You must be signed in to change notification settings - Fork 77
A7-5-2, RULE-8-2-10: callers of recursive functions reported as recursive #935
Copy link
Copy link
Open
Labels
Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressA 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.An issue related to observed false positives or false negatives.false-positiveAn issue representing a false positive report.An issue representing a false positive report.
Metadata
Metadata
Assignees
Labels
Difficulty-LowA false positive or false negative report which is expected to take <1 day effort to addressA 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.An issue related to observed false positives or false negatives.false-positiveAn issue representing a false positive report.An issue representing a false positive report.
Type
Fields
Give feedbackNo fields configured for Bug.
Affected rules
A7-5-2RULE-8-2-10Description
The query finds
RecursiveCall rcs and then reportsFunctionCall fcs wherefc.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.cppfile:We incorrectly get a result claiming that
test_calls_recursive_functionis recursive. This is incorrect and unnecessary, sincetest_recursive_functionis already flagged.