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