Bug ID: 84674
           Summary: Derived type name change makes a program segfault,
                    removing non_overridable
           Product: gcc
           Version: 8.0.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot
          Reporter: albandil at atlas dot cz
  Target Milestone: ---

Take the program code from , change derived type
name "t3" to "DerivedType" (three places in the code) and compile the result by
gfortran 7.3.0. It will compile fine, but result in segmentation fault at
runtime, even though the original code (with "t3") now runs all right.

When the modified code is compiled with gfortran 7.2.0 or ifort 17.0.0, it also
runs well, without crashing.

Finally, when "non_overridable" keyword on line 12 is removed (as indicated in
the commented line 13), the modified program runs well, too, even when compiled
by gfortran 7.3.0.

For reference, here is the failing code:

 module m
  implicit none

  type, abstract :: t1
   integer :: i
   procedure(i_f), pass(u), deferred :: ff
  end type t1

  type, abstract, extends(t1) :: t2
   procedure, non_overridable, pass(u) :: ff => f ! Segmentation fault 
   !procedure, pass(u) :: ff => f ! works
  end type t2

  type, extends(t2) :: DerivedType
  end type DerivedType

  abstract interface
   subroutine i_f(u)
    import :: t1
    class(t1), intent(inout) :: u
   end subroutine i_f
  end interface


  subroutine f(u)
   class(t2), intent(inout) :: u
    u%i = 3*u%i
  end subroutine f

 end module m

 program p

  use m

  implicit none

  class(t1), allocatable :: v

  v%i = 2
  call v%ff()
  write(*,*) v%i
 end program p

Reply via email to