From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 23EA53857812; Mon, 14 Sep 2020 14:45:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23EA53857812 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1600094704; bh=khyIVZBRPwM3j+DFLDsbNpd/u8GFWxinxk0gi/6krA4=; h=From:To:Subject:Date:From; b=CLZ0wyUUgG4cV1eUkqiNtctYTY0xLALW9y/Zt/whTQ1Ou/bRZLCSnvPzwoYqmeEdA 0G/03c0XKc6eBNyNteq+CO9nm+F8I15JkVTdC64ImliE/yOKH8OyCXfDnBkD04xtHC X1kfAT9ka9MhhrJTjowkqsheFhQO8SbFi2Uaoqr4= From: "igor.gayday at mu dot edu" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/97045] New: A wrong column is selected when addressing individual elements of unlimited polymorphic dummy argument Date: Mon, 14 Sep 2020 14:45:03 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: igor.gayday at mu dot edu X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Sep 2020 14:45:04 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97045 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 =3D reshape([(i, i =3D 1, 100)], [10, 10]) do i =3D 1, 3 print *, 'Column', i call write_array(arr(1:2, i))=20 end do contains subroutine write_array(array) class(*), intent(in) :: array(:) integer :: i do i =3D 1, size(array) select type (elem =3D> 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 wh= ole array and not individual elements, then every column is printed, as expecte= d. This issue was originally reported here: https://stackoverflow.com/questions/63841012/a-wrong-column-is-selected-whe= n-addressing-individual-elements-of-unlimited-poly=