This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: gcc-3.0: Obvious infinite recursion not detected
- To: fjh at cs dot mu dot oz dot au (Fergus Henderson)
- Subject: Re: gcc-3.0: Obvious infinite recursion not detected
- From: Joern Rennecke <amylaar at redhat dot com>
- Date: Thu, 5 Jul 2001 18:02:49 +0100 (BST)
- Cc: aoliva at redhat dot com (Alexandre Oliva), Ryszard dot Kabatek at softax dot pl,gcc at gcc dot gnu dot org
> The Mercury compiler issues a warning of the form
>
> foo.m:123: Warning: recursive call will lead to infinite recursion.
>
> for cases like this.
>
> > Under what conditions would it trigger?
>
> For the Mercury compiler, the conditions are that all of the following hold:
> - the call is to the same procedure that the call occurs in
> - the input arguments in the call are the same as the input parameters
> for the calling procedure
>
> This condition is very easy to check, since it can be done purely locally;
> the compiler doesn't need to do any data-flow analysis or anything like that.
>
> Unfortunately this condition relies on the side effect free nature of Mercury.
> It's not quite so easy in languages like C/C++, where you can have loops
> written using side effects that modify the termination condition of the loop;
But how about using a random number generator for the loop / recursion
exit condition? Or some input?