This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: RECURSIVE vs PURE and ELEMENTAL
On Sat, Aug 04, 2007 at 11:56:18AM -0700, Walter Spector wrote:
> Steve Kargl wrote:
> > ...
> > I guess I just don't understand what is failing for you.
>
> A couple of things:
>
> 1a.) Try making both 'factorial' and 'factorial_inner' ELEMENTAL.
> The first should be ok. The second should give an error at the
> point where it calls itself. (Or at least a warning when -pedantic
> is used.)
OK. gfc4x is gfortran 4.3.0-20070803 and gfc is gfortran 4.2.0 20070501
I'm running FreeBSD.
mobile:kargl[206] gfc4x -o z w1.f90
w1.f90:26.8:
r = factorial_inner (val * next, next - 1)
1
Error: Function 'factorial_inner' at (1) cannot call itself, as it is not
RECURSIVE
mobile:kargl[207] gfc -o z w1.f90
w1.f90:26.8:
r = factorial_inner (val * next, next - 1)
1
Error: Function 'factorial_inner' at (1) cannot call itself, as it is not
RECURSIVE
> 1b.) Try then making 'factorial_inner' PURE (but not RECURSIVE).
> This should also give a message at the point where it calls itself.
mobile:kargl[211] gfc4x -o z w1.f90
w1.f90:26.8:
r = factorial_inner (val * next, next - 1)
1
Error: Function 'factorial_inner' at (1) cannot call itself, as it is not
RECURSIVE
mobile:kargl[210] gfc -o z w1.f90
w1.f90:26.8:
r = factorial_inner (val * next, next - 1)
1
Error: Function 'factorial_inner' at (1) cannot call itself, as it is not
RECURSIVE
> 2.) I tried upgrading my gfortran to the latest cygwin binary.
> Unfortunately, it is now broken ("nothing happens" when I issue
> the gfortran command. The driver just returns a exit code of 1.)
I don't know cygwin. I wonder if your picking up the old 4.1.0
driver instead of a newer version.
Jerry, when you investigate the cygwin build can you also try
Walt's code. I simply can't reproduce his problem.
--
Steve