https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109451

--- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> ---
Created attachment 54842
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=54842&action=edit
Fix for this PR

To my surprise, the identified bug was very easily fixed and the associate
block that seemed to be OK was not compatible with array transfer in the print
statement. Once understood, this was easily fixed.

The testcase appears below. I will post asap.

Paul

! { dg-do run }
! Test fixes for PR109451
! Contributed by Harald Anlauf  <anl...@gcc.gnu.org>
!
  call dcs3(['abcd','efgh'])
contains
  subroutine dcs3(a)
    character(len=*), intent(in)  :: a(:)
    character(:),     allocatable :: b(:)
    b = a(:)
    call test (b, a, 1)
    associate (q => b(:))    ! no ICE but print repeated first element
      call test (q, a, 2)
      print *, q
    end associate
    associate (q => b(:)(:)) ! ICE
      call test (q, a, 3)
      associate (r => q(:)(1:3))
        call test (r, a(:)(1:3), 4)
      end associate
    end associate
    associate (q => b(:)(2:3))
      call test (q, a(:)(2:3), 5)
    end associate
  end subroutine dcs3
  subroutine test (x, y, i)
    character(len=*), intent(in) :: x(:), y(:)
    integer, intent(in) :: i
    if (any (x .ne. y)) stop i
  end subroutine test
end
! { dg-output " abcdefgh" }

Reply via email to