The program will crash if compile with version 4.4.3 or 4.3.2 but works with
4.1.2.

Main program is written in C. (see the following)
/* 
 * C file passdouble.c
 * To compile the program, using the following command.
 *    gcc passdouble.c requestdouble.o -lgfortran
*/
#include <stdio.h>
extern char* requestdouble_(double*,double*);
int main()
{
    double lat=10.0;
    double lon=20.0;
    requestdouble_(&lat,&lon);
    return 0;
}

The Fortran function is in the file requestdouble.f90 shown below.

! gfortran -c -g -Wall requestdouble.f90
 FUNCTION requestdouble(rlat,rlng)
!
  IMPLICIT NONE
!
! Arguments
!
! Input scalars
  REAL(KIND=8), INTENT(IN) :: rlat ! - latitude -
  REAL(KIND=8), INTENT(IN) :: rlng ! - longitude -
!
  CHARACTER(LEN=16) :: requestdouble
!  
  PRINT *, ' requestdouble rlat=',rlat,' rlng=',rlng
  requestdouble='1111111111111111'
  RETURN
 END FUNCTION requestdouble

Here is how it compiled and ran.

gfortran -c -g -Wall requestdouble.f90
gcc passdouble.c requestdouble.o -lgfortran
a.out
Bus error


-- 
           Summary: Bus Error: C program calls Fortran Function which has
                    returned value as Character string
           Product: gcc
           Version: 4.4.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: Lulin dot Song at gmail dot com


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45466

Reply via email to