| 1 |
! { dg-do run } |
| 2 |
! Test the fix for PR38802, in which the nulling of the result 'p' |
| 3 |
! in 'a_fun' would cause a segfault. |
| 4 |
! |
| 5 |
! Posted on the gfortran list by Marco Restelli http://gcc.gnu.org/ml/fortran/2009-01/ |
| 6 |
|
| 7 |
! |
| 8 |
module mod_a |
| 9 |
implicit none |
| 10 |
public :: a_fun, t_1, t_2 |
| 11 |
private |
| 12 |
type t_1 |
| 13 |
real :: coeff |
| 14 |
end type t_1 |
| 15 |
type t_2 |
| 16 |
type(t_1), allocatable :: mons(:) |
| 17 |
end type t_2 |
| 18 |
contains |
| 19 |
function a_fun(r) result(p) |
| 20 |
integer, intent(in) :: r |
| 21 |
type(t_2) :: p(r+1) |
| 22 |
p = t_2 ([t_1 (99)]) |
| 23 |
end function a_fun |
| 24 |
end module mod_a |
| 25 |
|
| 26 |
program test |
| 27 |
use mod_a, only: a_fun, t_1, t_2 |
| 28 |
implicit none |
| 29 |
type(t_2) x(1) |
| 30 |
x = a_fun(0) |
| 31 |
if (any (x(1)%mons%coeff .ne. 99)) STOP 1 |
| 32 |
end program test |