2 ! { dg-require-visibility "" }
3 ! Test the fix for PR61459 and PR58883.
5 ! Contributed by John Wingate <johnww@tds.net>
6 ! and Tao Song <songtao.thu@gmail.com>
12 public
:: f_segfault
, f_segfault_plus
, f_workaround
13 integer, dimension(2,2) :: b
= reshape([1,-1,1,1],[2,2])
17 function f_segfault(x
)
18 real, dimension(:), allocatable
:: f_segfault
19 real, dimension(:), intent(in
) :: x
20 allocate(f_segfault(2))
21 f_segfault
= matmul(b
,x
)
22 end function f_segfault
24 ! Sefaulted without the ALLOCATE as well.
25 function f_segfault_plus(x
)
26 real, dimension(:), allocatable
:: f_segfault_plus
27 real, dimension(:), intent(in
) :: x
28 f_segfault_plus
= matmul(b
,x
)
29 end function f_segfault_plus
31 function f_workaround(x
)
32 real, dimension(:), allocatable
:: f_workaround
33 real, dimension(:), intent(in
) :: x
34 real, dimension(:), allocatable
:: tmp
35 allocate(f_workaround(2),tmp(2))
38 end function f_workaround
45 real, dimension(2) :: x
= 1.0, y
48 if (any (f_segfault (x
) .ne
. y
)) call abort
49 if (any (f_segfault_plus (x
) .ne
. y
)) call abort
51 if (any (foo () .ne
. reshape([1,2,3,4,5,6,7,8],[2,4]))) call abort
54 integer, allocatable
:: foo(:,:)
55 integer, allocatable
:: temp(:)
57 temp
= [1,2,3,4,5,6,7,8]
58 foo
= reshape(temp
,[2,4])