https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107968
--- Comment #3 from anlauf at gcc dot gnu.org ---
Here's a variation of the testcase that suggests that argument association
(pointer dummy with an actual with target attribute) does not set up the
descriptor in a way that is expected later:
PROGRAM foo
implicit none
TYPE t_geographical_coordinates
REAL :: lon
REAL :: lat
END TYPE t_geographical_coordinates
TYPE t_vertices
REAL, POINTER :: vlon(:) => null()
REAL, POINTER :: vlat(:) => null()
END TYPE t_vertices
TYPE(t_vertices), POINTER :: vertices_pointer
TYPE(t_vertices), TARGET :: vertices_target
TYPE(t_geographical_coordinates), TARGET :: vertex(2)
! initialization
vertex%lon = 1
vertex%lat = 2
! obtain pointer to (non-contiguous) field
vertices_target%vlon => vertex%lon
! set pointer in a subroutine
CALL set_vertices_pointer(vertices_target) ! argument association broken?
! simple pointer association is ok:
vertices_pointer => vertices_target
write (0,*) "vertices_pointer%vlon:"
WRITE (0,*) vertices_pointer%vlon
WRITE (0,*) vertices_pointer%vlon(1:)
CONTAINS
SUBROUTINE set_vertices_pointer(vertices)
TYPE(t_vertices), POINTER, INTENT(IN) :: vertices
write (0,*) "vertices_target%vlon:"
WRITE (0,*) vertices_target%vlon
WRITE (0,*) vertices_target%vlon(1:)
write (0,*) "vertices %vlon:"
WRITE (0,*) vertices %vlon
WRITE (0,*) vertices %vlon(1:)
WRITE (0,*) (vertices %vlon(1:))
END SUBROUTINE set_vertices_pointer
END PROGRAM foo
This prints for me:
vertices_target%vlon:
1.00000000 1.00000000
1.00000000 1.00000000
vertices %vlon:
1.00000000 1.00000000
1.00000000 2.00000000
1.00000000 1.00000000
vertices_pointer%vlon:
1.00000000 1.00000000
1.00000000 1.00000000