------- Comment #7 from mikael at gcc dot gnu dot org 2010-08-31 23:36 ------- (In reply to comment #5) > (In reply to comment #2) > > Try compiling with -fdump-tree-original and inspecting the > > expected argument lists. You really don't want to use a > > function here. Use a subroutine. > > > > include <stdio.h> > > > > void requestdouble_(double*, double*, char *, int *len); > > > > int main() > > { > > char str[20]; > > int len; > > double lat=10.0; > > double lon=20.0; > > requestdouble_(&lat, &lon, str, &len); > > return 0; > > } > > subroutine requestdouble(rlat,rlng,str) > > IMPLICIT NONE > > REAL(KIND=8), INTENT(IN) :: rlat ! - latitude - > > REAL(KIND=8), INTENT(IN) :: rlng ! - longitude - > > CHARACTER(LEN=*) :: str > > PRINT *, ' requestdouble rlat=', rlat,' rlng=', rlng > > str='1111111111111111' > > RETURN > > END subroutine requestdouble > > > Thanks. I do know how to work around it with subroutine which I already did in > my program. But it doesn't explain why 4.1.2 version allows return character > string from function. Our program works well until the gcc upgrade. > Is this new standard? > This is internal plumbing you should not be relying on, specific to the compiler and to the compiler version (though for gfortran it has been unchanged for some time). The note 15.22 from the fortran standard shows an example how to operate properly between C and fortran with subroutine character parameters. It doesn't deal with function return values though. For sure you need the bind(c) attribute on your function and probably explicit character length too.
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45466