public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/97045] New: A wrong column is selected when addressing individual elements of unlimited polymorphic dummy argument
@ 2020-09-14 14:45 igor.gayday at mu dot edu
  2020-09-20 16:57 ` [Bug fortran/97045] " pault at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: igor.gayday at mu dot edu @ 2020-09-14 14:45 UTC (permalink / raw)
  To: gcc-bugs

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-10-31  7:32 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-14 14:45 [Bug fortran/97045] New: A wrong column is selected when addressing individual elements of unlimited polymorphic dummy argument igor.gayday at mu dot edu
2020-09-20 16:57 ` [Bug fortran/97045] " pault at gcc dot gnu.org
2020-09-25 15:34 ` pault at gcc dot gnu.org
2020-09-30 12:44 ` cvs-commit at gcc dot gnu.org
2023-10-30 19:42 ` anlauf at gcc dot gnu.org
2023-10-31  7:32 ` pault at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).