Iso_c_binding: interface to a C function returning a string

Does the result change if the function

   module function xbsf_get_error_string(ierr) result(str)
      integer(xbsf_int_t), value :: ierr
      character(len = :), allocatable :: str

is replaced by a subroutine (such that str is passed as an actual argument)? Also, in the function case, does it work correctly if the result variable is declared as a character string of fixed size (say, character(100) :: str)? I remember I saw a similar issue for allocatable strings in the context of recursive functions or OpenMP. Because it might also affect other cases, I think it would be great if a reproducible code example could be created (e.g. for submission to the gfortran issue site).

1 Like