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

            Bug ID: 89200
           Summary: Erroneous copying of a derived type with a
                    deferred-length character array component
           Product: gcc
           Version: 9.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: damian at sourceryinstitute dot org
  Target Milestone: ---

$cat corrupted-component.f90 
  type foo
    character(len=:), allocatable :: string
  end type
  type foo_list
    type(foo), allocatable :: entry(:)
  end type
  type(foo_list) list
  list = foo_list([foo('1'), foo('2')])
  print*, list%entry(1)%string, list%entry(2)%string
end

$gfortran corrupted-component.f90 

$./a.out
 11

$gfortran --version
GNU Fortran (GCC) 9.0.1 20190125 (experimental)

The same result obtains if the intrinsic assignment is replaced
by a source allocation of the form

allocate(list%entry, source = [foo('1'), foo('2')] )

Reply via email to