public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "pault at gcc dot gnu.org" <gcc-bugzilla@gcc.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 [thread overview] Message-ID: <bug-97045-4-ed5MB5TUMa@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-97045-4@http.gcc.gnu.org/bugzilla/> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=97045 --- Comment #2 from Paul Thomas <pault at gcc dot gnu.org> --- Created attachment 49272 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=49272&action=edit Updated patch It turned out that with the original patch, character payloads of the unlimited 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 <igor.gayday@mu.edu> ! program test_prg implicit none integer :: i integer, allocatable :: arr(:, :) character(kind = 1, len = 2), allocatable :: chr(:, :) character(kind = 4, len = 2), allocatable :: chr4(:, :) arr = reshape ([(i, i = 1, 9)], [3, 3]) do i = 1, 3 call write_array(arr(1:2, i), i) end do chr = reshape([(char (i)//char (i+1), i = 65, 83, 2)], [3, 3]) do i = 1, 3 call write_array (chr(1:2, i), i) end do chr4 = reshape([(char (i, kind = 4)//char (i+1, kind = 4), i = 65, 83, 2)], & [3, 3]) do i = 1, 3 call write_array (chr4(1:2, i), i) end do contains subroutine write_array(array, j) class(*), intent(in) :: array(:) integer :: i = 2 integer :: j, k select type (elem => array(i)) type is (integer) k = 3*(j-1)+i if (elem .ne. k) stop 1 type is (character(kind = 1, len = *)) k = 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 = 4, len = *)) k = 63 + 2*(3*(j-1)+i) if (elem .ne. char (k, kind = 4)//char (k+1, kind = 4)) stop 3 end select end subroutine end program
next prev parent reply other threads:[~2020-09-25 15:34 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-09-14 14:45 [Bug fortran/97045] New: " 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 [this message] 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
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-97045-4-ed5MB5TUMa@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).