https://gcc.gnu.org/bugzilla/show_bug.cgi?id=88247
Paul Thomas <pault at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pault at gcc dot gnu.org Assignee|unassigned at gcc dot gnu.org |pault at gcc dot gnu.org --- Comment #3 from Paul Thomas <pault at gcc dot gnu.org> --- Created attachment 45594 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=45594&action=edit A fix for the PR and more besides This represents where I have got to: program p type t character(:), allocatable :: c character(:), dimension(:), allocatable :: d end type type(t), allocatable :: x call foo ('abcdef','ghijkl') associate (y => [x%c(:)]) if (y(1) .ne. 'abcdef') stop 1 end associate call foo ('ghi','ghi') associate (y => [x%c(2:)]) if (y(1) .ne. 'hi') stop 2 end associate call foo ('lmnopq','ghijkl') associate (y => [x%c(:3)]) ! if (y(1) .ne. 'lmn') stop 3 end associate call foo ('abcdef','ghijkl') associate (y => [x%c(2:4)]) if (y(1) .ne. 'bcd') stop 4 end associate call foo ('lmnopqrst','ghijklmno') associate (y => x%d(:)) if (y(1) .ne. 'lmnopqrst') stop 5 end associate ! Substrings of arrays still do not work. ! associate (y => x%d(:)(2:4)) ! if (y(1) .ne. 'mno') stop 6 ! end associate ! This is what I am working on now: call foo ('abcdef','ghijkl') associate (y => [x%d(:)]) print *, y(1), ' ', y(2) if (y(1) .ne. 'abcdef') stop 7 end associate ! call foo ('lmnopqrst','ghijklmno') ! associate (y => [x%d(2:2)]) ! if (y(1) .ne. 'ghijklmno') print *, y(1) ! end associate deallocate (x) contains subroutine foo (c1, c2) character(*) :: c1, c2 if (allocated (x)) deallocate (x) allocate (x) x%c = c1 x%d = [c1, c2] end subroutine foo end