From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 12E323971C54; Fri, 25 Sep 2020 15:34:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12E323971C54 From: "pault at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/97045] A wrong column is selected when addressing individual elements of unlimited polymorphic dummy argument Date: Fri, 25 Sep 2020 15:34:12 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed 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: pault at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: pault at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: 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: Fri, 25 Sep 2020 15:34:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D97045 --- Comment #2 from Paul Thomas --- Created attachment 49272 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D49272&action=3Dedit Updated patch It turned out that with the original patch, character payloads of the unlim= ited polymorphic array were still not behaving properly - see the test below. I am about to submit to the fortran list. Thanks again Paul ! { dg-do run } ! ! Test the fix for PR97045. The report was for the INTEGER version. Testing ! revealed a further bug with the character versions. ! ! Contributed by Igor Gayday ! program test_prg implicit none integer :: i integer, allocatable :: arr(:, :) character(kind =3D 1, len =3D 2), allocatable :: chr(:, :) character(kind =3D 4, len =3D 2), allocatable :: chr4(:, :) arr =3D reshape ([(i, i =3D 1, 9)], [3, 3]) do i =3D 1, 3 call write_array(arr(1:2, i), i) end do chr =3D reshape([(char (i)//char (i+1), i =3D 65, 83, 2)], [3, 3]) do i =3D 1, 3 call write_array (chr(1:2, i), i) end do chr4 =3D reshape([(char (i, kind =3D 4)//char (i+1, kind =3D 4), i =3D 65= , 83, 2)], & [3, 3]) do i =3D 1, 3 call write_array (chr4(1:2, i), i) end do contains subroutine write_array(array, j) class(*), intent(in) :: array(:) integer :: i =3D 2 integer :: j, k select type (elem =3D> array(i)) type is (integer) k =3D 3*(j-1)+i if (elem .ne. k) stop 1 type is (character(kind =3D 1, len =3D *)) k =3D 63 + 2*(3*(j-1)+i) if (elem .ne. char (k)//char (k+1)) print *, elem, " ", char (k)//char (k+1) type is (character(kind =3D 4, len =3D *)) k =3D 63 + 2*(3*(j-1)+i) if (elem .ne. char (k, kind =3D 4)//char (k+1, kind =3D 4)) stop 3 end select end subroutine end program=