https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97045
Bug ID: 97045 Summary: A wrong column is selected when addressing individual elements of unlimited polymorphic dummy argument Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: igor.gayday at mu dot edu Target Milestone: --- Consider the following Fortran program: program test_prg implicit none integer :: i integer, allocatable :: arr(:, :) arr = reshape([(i, i = 1, 100)], [10, 10]) do i = 1, 3 print *, 'Column', i call write_array(arr(1:2, i)) end do contains subroutine write_array(array) class(*), intent(in) :: array(:) integer :: i do i = 1, size(array) select type (elem => array(i)) type is (integer) print '(I0)', elem end select end do end subroutine subroutine write_array_alt(array) class(*), intent(in) :: array(:) integer :: i select type (array) type is (integer) print '(I0)', array end select end subroutine end program Compiled with gfortran 9.3.0 (and 10.2), the program prints: Column 1 1 2 Column 2 21 22 Column 3 41 42 As you can see, it skips every other column. If I replace the call to write_array with the call to write_array_alt, where I select type of the whole array and not individual elements, then every column is printed, as expected. This issue was originally reported here: https://stackoverflow.com/questions/63841012/a-wrong-column-is-selected-when-addressing-individual-elements-of-unlimited-poly