fortran-src icon indicating copy to clipboard operation
fortran-src copied to clipboard

remove DoSpec from ExpImpliedDo

Open raehik opened this issue 2 years ago • 3 comments

raehik avatar May 13 '22 14:05 raehik

gfortran has some strange behaviour for implied DO loops:

  • used in a print, the final value of the loop variable is retained
  • used in an assignment, the loop variable is left untouched
program main
    integer i
    integer is(5)
    print *, i                  ! 0
    print *, ( i, i = -1, 2 )
    print *, i                  ! 3
    is = [ (i, i = 2, 6) ]
    print *, is
    print *, i                  ! 3
end

Putting aside the print behaviour, they feel like syntactic sugar. gfortran even tells you if it's the wrong shape for the assigning array, implying it evaluates them to arrays during compilation. Based on this, I feel the assignment inside implied DOs isn't a real assignment, just syntax reuse.

raehik avatar May 13 '22 14:05 raehik

The tricky thing is that now we've lost the data flow path due to an assignment...!

dorchard avatar May 16 '22 11:05 dorchard

I wouldn't count on gfortran for sensible/reliable behaviour.

mrd avatar May 16 '22 12:05 mrd