2 ! PR 38536 - don't reject substring of length one
3 ! Original test case by Scot Breitenfeld
4 SUBROUTINE test(buf, buf2, buf3, n)
5 USE, INTRINSIC :: ISO_C_BINDING
7 CHARACTER(LEN=*), INTENT(INOUT), TARGET :: buf
8 INTEGER, INTENT(in) :: n
9 CHARACTER(LEN=*), INTENT(INOUT), DIMENSION(1:2), TARGET :: buf2
10 CHARACTER(LEN=3), TARGET :: buf3
13 f_ptr = C_LOC(buf(1:1)) ! Used to fail
14 ! Error: CHARACTER argument 'buf' to 'c_loc'
15 ! at (1) must have a length of 1
16 f_ptr = C_LOC(buf2(1)(1:1)) ! PASSES
18 f_ptr = C_LOC(buf(n:n))
20 f_ptr = C_LOC(buf3(3:))