- Notifications
You must be signed in to change notification settings - Fork69
Description
Affected rules
A7-5-2RULE-8-2-10
Description
The query findsRecursiveCall 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 thetest.cpp file:
inttest_calls_recursive_function(int i) {test_recursive_function(i);// COMPLIANT}
We incorrectly get a result claiming thattest_calls_recursive_function is recursive. This is incorrect and unnecessary, sincetest_recursive_function is already flagged.