This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: gcc-3.0: Obvious infinite recursion not detected


> 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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]