-
Notifications
You must be signed in to change notification settings - Fork 68
Description
Affected rules
A7-5-2
RULE-8-2-10
Description
The query finds RecursiveCall rc
s and then reports FunctionCall fc
s 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.