From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3971A3858D28; Sat, 9 Apr 2022 19:21:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3971A3858D28 From: "townsend at astro dot wisc.edu" 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 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 11.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: townsend at astro dot wisc.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: Sat, 09 Apr 2022 19:21:39 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105205 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 =3D ['foo','bar','biz','buz'] b =3D a do i =3D 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 expect= ed output: >> foo bar biz buz << It seems as if only the first element of c is being copied correctly. cheers, Rich=