2 ! Tests the fix for PR64578.
4 ! Contributed by Damian Rouson <damian@sourceryinstitute.org>
7 real, allocatable
:: component(:)
9 type (foo
), target
:: f
10 class(*), pointer :: ptr(:)
11 allocate(f
%component(1),source
=[0.99])
12 call associate_pointer(f
,ptr
)
15 if (abs (ptr(1) - 0.99) > 1e-5) STOP 1
17 ptr
=> return_pointer(f
) ! runtime segmentation fault
18 if (associated(return_pointer(f
)) .neqv
. .true
.) STOP 2
21 if (abs (ptr(1) - 0.99) > 1e-5) STOP 3
24 subroutine associate_pointer(this
, item
)
25 class(foo
), target
:: this
26 class(*), pointer :: item(:)
27 item
=> this
%component
29 function return_pointer(this
)
30 class(foo
), target
:: this
31 class(*), pointer :: return_pointer(:)
32 return_pointer
=> this
%component