Bug 42309 - Problem with a pointer array passed to a subroutine
Paul Richard Thomas
paul.richard.thomas@gmail.com
Fri Jul 7 15:53:00 GMT 2017
In the course of working on PR34640, I encountered a conflict between
the treatment of the array descriptors when an actual pointer is
passed to a dummy pointer in two different testcases.
In the above PR, one-based lbounds were anticipated by the reporter
and the fix implemented this in subref_array_4.f90.
In char_result_4.f90 it is assumed that the descriptor bounds are
passed to the procedure.
It is my belief that the latter is correct, as evidenced by the
following extract from the F2003 standard:
C.9.6
If a dummy argument is declared to be a pointer, it may be matched
only by an actual argument that also is a pointer, and the
characteristics of both arguments shall agree. A model for such an
association is that descriptor values of the actual pointer are copied
to the dummy pointer.....
In this case, subroutine Z(Q) in subref_array_4.f90 should be
SUBROUTINE Z(Q)
INTEGER, POINTER :: Q(:)
integer :: off
off = lbound(Q, 1) - 1
Q(1+off : 3+off : 2) = 999
END SUBROUTINE Z
instead of
SUBROUTINE Z(Q)
INTEGER, POINTER :: Q(:)
Q(1:3:2) = 999
END SUBROUTINE Z
Comments?
Paul
More information about the Fortran
mailing list