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

Paul Thomas <pault at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |pault at gcc dot gnu.org

--- Comment #7 from Paul Thomas <pault at gcc dot gnu.org> ---
Stranger and stranger. Not only does the removal of a line in a subroutine that
is not called make the testcase work but explicitly using the subroutine to do
the allocation works as well:

module test_case

  implicit none

  type :: array_t
     integer, dimension(:), allocatable :: child
   contains
     procedure :: write_raw => particle_write_raw
     procedure :: read_raw => particle_read_raw
  end type array_t

  type :: container_t
     type(array_t), dimension(:), allocatable :: array
  end type container_t

contains

  subroutine proc ()
    type(container_t) :: container
    integer :: unit, child

    allocate (container%array(1))
!    allocate (container%array(1)%child (1), source = [2])
    call container%array(1)%read_raw ()

    unit = 33
    open (unit, action="readwrite", form="unformatted", status="scratch")
    print *, 1
    call container%array(1)%write_raw (unit)
    print *, 2
    rewind (unit)
    read(unit) child
    print *, "value from scratch file = ", child
  end subroutine proc

  subroutine particle_write_raw (array, u)
    class(array_t), intent(in) :: array
    integer, intent(in) :: u
    write (u) array%child
  end subroutine particle_write_raw

  subroutine particle_read_raw (array)
    class(array_t), intent(out) :: array
    allocate (array%child (1), source = [99])    ! comment this out
  end subroutine particle_read_raw

end module test_case

program main
  use test_case
  call proc ()
  end program main

I have taken it, although I might need help from you Thomas since I rather
suspect something is bad in the i/o library.

Paul

Reply via email to