Direct recursion detection possible?

Steven Schveighoffer schveiguy at gmail.com
Thu May 25 02:30:35 UTC 2023


On 5/24/23 7:04 PM, Cecil Ward wrote:

> Is it possible for our compilers to detect direct infinite recursion ? 
> I’m ignoring the indirect call case, and I’m also ignoring anything 
> involving function pointers, so given those restrictions, we will be 
> able to see that the generated code of a routine is calling its own 
> address, because that address is a literal and we know what the current 
> function is that we’re currently in.

Not in the general case. Direct recursion is a common pattern (direct 
inifite recursion obviously is not desired, but detecting that is the 
halting problem).

-Steve


More information about the Digitalmars-d mailing list