Skip to content

Commit a934562

Browse files
committed
Fix test on GCC < 9
1 parent 97273d1 commit a934562

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Examples/test-suite/fortran/fortran_bindc_runme.F90

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,18 +110,22 @@ subroutine test_strings
110110
use fortran_bindc
111111
use ISO_C_BINDING
112112
implicit none
113+
character(kind=c_char, len=*), parameter :: mystring = "I'm a string!"
114+
#if __GNUC__ >= 9
113115
type(C_PTR) :: cptr
114116
character(kind=c_char, len=:), pointer :: cstrptr
115-
character(kind=c_char, len=*), parameter :: mystring = "I'm a string!"
117+
#endif
116118

117119
ASSERT(strlen(mystring // C_NULL_CHAR) == len(mystring))
118120

119-
! Note: not sure if the C-to-Fortran here is truly defined behavior
121+
#if __GNUC__ >= 9
122+
! Note: this seems to be allowed in GCC 9 but not before. I'm not sure that it's the correct behavior.
120123
cptr = getstr(1)
121124
call c_f_pointer(cptr, cstrptr)
122125
ASSERT(associated(cstrptr))
123126
ASSERT(strlen(cstrptr) == 3)
124127
ASSERT(cstrptr(1:3) == "one")
128+
#endif
125129

126130
end subroutine
127131

0 commit comments

Comments
 (0)