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


On 05-Jul-2001, Joern Rennecke <amylaar@redhat.com> wrote:
> [Fergus wrote:]
> > 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
...
> > 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?

Updating a random number generator state or performing input are side effects.

In Mercury, random number generation and I/O are handled by passing
arguments representing the random number generator state
or the I/O state (a.k.a. the "state of the world").
These can be passed either explicitly, or using various kinds of syntactic
sugar for implicitly threading state variables though your computations.
But at the point where we detect this warning, such syntactic sugar has
all been expanded out, and so any side effects are visible to the compiler
as input and/or output arguments.

-- 
Fergus Henderson <fjh@cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.


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