[4.5, Patch, Fortran] Run-time check for recursion

Daniel Kraft d@domob.eu
Sat Dec 6 13:28:00 GMT 2008


Tobias Burnus wrote:
> Hi all,
> 
> the following adds a run-time check for calling a procedure recursively
> without without marking it as RECURSIVE. It relies on Paul's/FX's memory
> patch, which add the needed option. (I'm also not documenting it, hoping
> that the other patch will also adding the needed documentation.)
> 
> Daniel, I hope you have not yet started implementing this, but I needed
> yesterday evening something which I could do productively.

Hi Tobias,

no problem, I didn't yet find time to start on this!

Regarding your patch, I don't seem to see where the variable is reset to 
false when the function exits?  As I understand, the generated code 
looks like:

void function ()
{
   static bool is_recursive = false;
   if (is_recursive)
     error ();
   is_recursive = true;
   ...
}

And if you had code like

function ()
function ()

This should fail even though the call is not recursive.  Does code like

SUBROUTINE foo ()
END SUBROUTINE foo ()

PROGRAM main ()
   CALL foo ()
   CALL foo ()
END PROGRAM main

work?  Apart from that, the patch looks ok for me.

Thanks!

Daniel

-- 
Done:  Arc-Bar-Cav-Rog-Sam-Val-Wiz
To go: Hea-Kni-Mon-Pri-Ran-Tou



More information about the Fortran mailing list