James Giles said:
> "Jan van Oosterwijk" <[log in to unmask]> wrote:
> ...
> > > character*10 a
> > > a = '1234567890'
> > > forall(i=1:10) a(i:i) = a(11-i:11-i)
> > > print *,a
> > > end
> > >
> > >Is this standard conforming ? More exactly, are
> > >character substrings allowed in a FORALL statement ?
> >
> > I think it is standard conforming; but ...
> > Two compilers give different results:
> >
> > The first gives the following:
> >
> > E:\Fortran\Test>f95 vezina.f95
> > 1636 warning on line 6 of vezina.f95: This assignment may violate the
> > many-to-one assignment restriction of the FORALL.
I think that the compiler is just not doing a good enough analysis to
notice that the lhs of the assignment is unique per iteration. You'd
think that if they're going to go to the effort of noticing anything,
that they'd get a simple case like this one right though.
Anyway, since it's only a warning message, provided it gets the right
answer on execution the compiler is conforming. (It only says "may",
not that it does.)
> I would say the latter is conforming. However, there's a slight grey
> area here. Since A is a scalar character variable and not an array, it
> *could* be argued that the left hand side was the same for all i, even
No, I don't think this could be argued; or at least not convincingly.
This theory is not supported by the standard. Separate character
substrings are separate objects just as much as separate array elements
are separate objects.
Anyway, as long as the "right" answer is given, both compilers could be
conforming. But I'd suggest complaining to the vendor of the first one,
as the warning is clearly spurious.
Cheers,
--
...........................Malcolm Cohen, NAG Ltd., Oxford, U.K.
([log in to unmask])
|