3 ! Checks that PR60593 is fixed (Revision: 214757)
5 ! Contributed by Steve Kargl <kargl@gcc.gnu.org>
7 ! Main program added for this test.
14 character(:), allocatable
:: string
18 function strlen(s
) bind(c
,name
='strlen')
21 type(c_ptr
), intent(in
), value
:: s
22 integer(c_size_t
) :: strlen
28 function C2FChar(c_charptr
) result(res
)
30 type(c_ptr
), intent(in
) :: c_charptr
31 character(:), allocatable
:: res
32 character(kind
=c_char
,len
=1), pointer :: string_p(:)
34 c_str_len
= int(len(c_charptr
))
35 call c_f_pointer(c_charptr
, string_p
, [c_str_len
])
36 allocate(character(c_str_len
) :: res
)
37 forall (i
= 1:c_str_len
) res(i
:i
) = string_p(i
)
46 character(20), target
:: str
48 str
= "abcdefghij"//char(0)
50 if (len (C2FChar (cptr
)) .ne
. 10) STOP 1
51 if (C2FChar (cptr
) .ne
. "abcdefghij") STOP 2