http://gcc.gnu.org/bugzilla/show_bug.cgi?id=47240
Summary: segfault with procedure pointer component
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: [email protected]
ReportedBy: [email protected]
The following code gives a segmentation fault.
module element_defs_m
type tfunc_p
procedure (dum_tfunc), pointer, nopass :: p => null()
end type tfunc_p
type coefficients_t
type(tfunc_p), allocatable, dimension(:) :: tfunc1
end type coefficients_t
contains
function dum_tfunc ( n, x )
integer, intent(in) :: n
real, intent(in), dimension(:) :: x
real, dimension(n,n) :: dum_tfunc
dum_tfunc = 0
end function dum_tfunc
end module element_defs_m
module m1
use element_defs_m
contains
subroutine scalar_diffusion2_elem ( coefficients)
type(coefficients_t), intent(in) :: coefficients
real :: coef (2,2)
call evaluate_tensor_coefficient ( coefficients%tfunc1(1)%p, coef )
print *, coef
end subroutine scalar_diffusion2_elem
subroutine evaluate_tensor_coefficient ( tfunc, coef )
interface
function tfunc ( n, x )
integer, intent(in) :: n
real, intent(in), dimension(:) :: x
real, dimension(n,n) :: tfunc
end function tfunc
end interface
real, dimension(:,:), intent(out) :: coef
real :: x(2)=0
coef = tfunc( n=2, x=x )
end subroutine evaluate_tensor_coefficient
end module m1
program t
use m1
type(coefficients_t) :: coefficients
allocate(coefficients%tfunc1(1))
coefficients%tfunc1(1)%p => dum_tfunc
call scalar_diffusion2_elem ( coefficients )
end program t