possible bug for function returning derived type (trunk binaries)
marco restelli
mrestelli@gmail.com
Sat Jan 10 10:40:00 GMT 2009
Dear all,
the attached code produces a segmentation fault with the latest
trunk binaries. The code looks fine to me, and it runs with ifort and
g95.
Best regards,
Marco Restelli
$ gfortran test.f90 -o test
$ ./test
Segmentation fault
$ gfortran --version
GNU Fortran (GCC) 4.4.0 20090110 (experimental) [trunk revision 143243]
System:
Linux 2.6.23-gentoo-r6 x86_64 AMD Turion(tm) 64 Mobile Technology
ML-32 AuthenticAMD GNU/Linux
module mod_a
implicit none
public :: a_fun, t_1, t_2
private
type t_1
real :: coeff
end type t_1
type t_2
type(t_1), allocatable :: mons(:)
end type t_2
contains
function a_fun(r) result(p)
integer, intent(in) :: r
type(t_2) :: p(r+1)
! Using an allocatable works
!type(t_2), allocatable :: p(:)
! allocate(p(r+1))
write(*,*) 'shape(p) is ', shape(p)
end function a_fun
end module mod_a
program test
use mod_a, only: a_fun, t_1, t_2
implicit none
type(t_2) x(1)
x = a_fun(0)
end program test
More information about the Fortran
mailing list