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

            Bug ID: 93158
           Summary: Coarray ICE when module and submodule are in separate
                    files
           Product: gcc
           Version: 10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: damian at sourceryinstitute dot org
  Target Milestone: ---

The ICE demonstrated below disappears if any one of the following is true:
1. The module and submodule are in the same file, or
2. The coarray is moved from the submodule to the module, or
3. The halo_data component is non-polymorphic.

$ cat surfaces_interface.f90 
module surfaces_interface
  type package
  end type

  type surfaces
    class(package), allocatable  :: halo_data
  end type

  interface
    module subroutine set_halo_data()
    end subroutine
  end interface
end module

$ cat surfaces_implementation.f90 
submodule(surfaces_interface) surfaces_implementation
  type(surfaces) singleton[*]
contains
  module procedure set_halo_data
  end procedure
end submodule

$ gfortran -fcoarray=single -c surfaces_interface.f90
surfaces_implementation.f90 
f951: internal compiler error: in gfc_get_derived_type, at
fortran/trans-types.c:2843
libbacktrace could not find executable to open

$ gfortran --version
GNU Fortran (GCC) 10.0.0 20190926 (experimental)

However, even with fixes 2 and 3 above, an ICE still occurs if all of the
following are true:
1. The halo_data component is made polymorphic, and
2. The subroutine allocates or assigns to the component, and
3. The module and submodule are in a separate file.

$ cat surfaces_interface.f90 
module surfaces_interface
  type package
  end type

  type surfaces
    class(package), allocatable :: halo_data
  end type

  type(surfaces) singleton[*]

  interface
    module subroutine set_halo_data()
    end subroutine
  end interface
end module

$ cat surfaces_implementation.f90 
submodule(surfaces_interface) surfaces_implementation
contains
  module procedure set_halo_data
    allocate(package::singleton%halo_data)
  end procedure
end submodule

$ gfortran -fcoarray=single -c surfaces_interface.f90
surfaces_implementation.f90 
surfaces_implementation.f90:4:0:

    4 |     allocate(package::singleton%halo_data)
      | 
internal compiler error: in gfc_get_derived_type, at fortran/trans-types.c:2843

Issues with file scope appear to be the unifying theme.

Reply via email to