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

            Bug ID: 85042
           Summary: Empty derived type allocation ICE
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: brichardson at structint dot com
  Target Milestone: ---

Given an empty, abstract derived type, and an empty derived type which extends
from it, trying to assign to an allocatable variable of the abstract class
causes the compiler to segfault.

The bug can be reproduced using the following code and commands.

the_types_m.f90

module the_types_m
    implicit none
    private

    type, public, abstract :: Abst_t
    end type Abst_t

    type, public, extends(Abst_t) :: Derived_t
    end type Derived_t

    public :: Derived
contains
    pure function Derived()
        type(derived_t) :: Derived

        Derived = Derived_t()
    end function Derived
end module the_types_m

cause_sefault.f90

module cause_segfault
    use the_types_m, only: Abst_t, Derived

    implicit none

contains
    subroutine the_problem
        class(Abst_t), allocatable :: var

        var = Derived()
    end subroutine the_problem
end module cause_segfault

compile commands

gfortran -c the_types_m.f90
gfortran -c cause_segfault.f90
cause_segfault.f90:10:0:

         var = Derived()

internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <file:///usr/share/doc/gcc-7/README.Bugs> for instructions.

Reply via email to