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

            Bug ID: 61284
           Summary: non_overridable produces segmentation fault
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mrestelli at gmail dot com

The attached code produces a segmentation fault when including the
non_overridable attribute in t2.

$ gfortran --version
GNU Fortran (GCC) 4.10.0 20140508 (experimental)

$ ./bhg 

Program received signal SIGSEGV: Segmentation fault - invalid memory reference.

Backtrace for this error:
#0  0x7F46D0A23797
#1  0x7F46D0A23D64
#2  0x7F46CFF5453F
#3  0x0



module m
 implicit none

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

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

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

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

contains

 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

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

Reply via email to