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

            Bug ID: 128230
           Summary: Incorrect indexing of a polymorphic assumed-shape
                    dummy array
           Product: gcc
           Version: 16.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: neil.n.carlson at gmail dot com
  Target Milestone: ---

The follow example demonstrates the incorrect indexing of a polymorphic
assumed-shape dummy array when the actual argument has a non-unit lower bound.
Bounds inquiries report the correct dummy bounds, but element addressing
appears to use the actual argument's indices without rebasing them.

program repro
  implicit none
  type :: t
    integer :: value
  end type
  type(t) :: a(0:1) = [t(42), t(99)]
  call check(a)
contains
  subroutine check(x)
    class(t), intent(in) :: x(:)
    print *, x(1)%value ! Expected: 42
  end subroutine
end program

Returns 99 instead of the expected 42.

Reply via email to