Bug 61284 - [OOP] non_overridable produces segmentation fault
Summary: [OOP] non_overridable produces segmentation fault
Status: RESOLVED DUPLICATE of bug 78443
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2014-05-22 11:04 UTC by mrestelli
Modified: 2016-11-22 11:43 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2014-05-22 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mrestelli 2014-05-22 11:04:09 UTC
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
Comment 1 Dominique d'Humieres 2014-05-22 11:16:35 UTC
Confirmed from 4.7 up to trunk (4.10). Likely related to pr61115.
Comment 2 janus 2016-11-22 11:43:48 UTC
I think this is the same problem as PR78443. The fix posted there also fixes the test case here.

*** This bug has been marked as a duplicate of bug 78443 ***