1! { dg-do run }
2!
3! Test the fix for PR61147.
4!
5! Contributed by Thomas Clune  <Thomas.L.Clune@nasa.gov>
6!
7module B_mod
8
9   type :: B
10      character(:), allocatable :: string
11   end type B
12
13contains
14
15   function toPointer(this) result(ptr)
16      character(:), pointer :: ptr
17      class (B), intent(in), target :: this
18
19         ptr => this%string
20
21   end function toPointer
22
23end module B_mod
24
25program main
26   use B_mod
27
28   type (B) :: obj
29   character(:), pointer :: p
30
31   obj%string = 'foo'
32   p => toPointer(obj)
33
34   If (len (p) .ne. 3) call abort
35   If (p .ne. "foo") call abort
36
37end program main
38
39
40