public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "townsend at astro dot wisc.edu" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/105205] New: Incorrect assignment of derived type with allocatable, deferred-length character component
Date: Sat, 09 Apr 2022 19:21:39 +0000	[thread overview]
Message-ID: <bug-105205-4@http.gcc.gnu.org/bugzilla/> (raw)

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105205

            Bug ID: 105205
           Summary: Incorrect assignment of derived type with allocatable,
                    deferred-length character component
           Product: gcc
           Version: 11.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: townsend at astro dot wisc.edu
  Target Milestone: ---

I've run into problems with assignment of derived types containing an
allocatable array of deferred-length strings. Example program:

---
program alloc_char_type
   implicit none
   type mytype
      character(:), allocatable :: c(:)
   end type mytype
   type(mytype) :: a
   type(mytype) :: b
   integer :: i
   a%c = ['foo','bar','biz','buz']
   b = a
   do i = 1, size(b%c)
      print *,b%c(i)
   end do
end
---

Running with gfortran 10.2.0 or 11.2.0, I get the output:

>>
 foo



<<

If I hard-code the length of the c component (to, say, 3), I get the expected
output:

>>
 foo
 bar
 biz
 buz
<<

It seems as if only the first element of c is being copied correctly.

cheers,

Rich

             reply	other threads:[~2022-04-09 19:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-09 19:21 townsend at astro dot wisc.edu [this message]
2023-03-28  9:55 ` [Bug fortran/105205] " pault at gcc dot gnu.org
2023-04-08  8:04 ` cvs-commit at gcc dot gnu.org
2023-04-08  9:37 ` 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-105205-4@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: link
Be 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).