[Bug fortran/20178] New: COMPLEX function returns incompatible with g77

gcc-bugzilla at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Wed Feb 23 23:29:00 GMT 2005



A function returning a COMPLEX value cannot be compiled in g77 and
called from gfortran (or vice versa) - doing so results in a segfault
or incorrect results.  (See test case below.)

This is a problem, since for the near future g77 and gfortran are
likely to coexist on many systems, and incompatible calling
conventions for F77 code means that libraries like the BLAS will have
to be provided in two flavors (g77 and gfortran) on the same system, a
major headache for users (not to mention distributors).

Note that COMPLEX argument passing seems to be okay (the below test
case works fine if it is switched from a function into a subroutine).

Environment:
System: Linux fftw.org 2.6.3-1-686-smp #2 SMP Tue Feb 24 20:29:08 EST 2004 i686 GNU/Linux
Architecture: i686

	
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../configure --prefix=/home/stevenj/gcc4 --enable-languages=c,f95

How-To-Repeat:
Create two files, arg1.f and arg1tst.f, consisting of:

arg1.f:
      complex function arg1(x, y)
      complex x, y
      arg1 = x + y
      return
      end

arg1tst.f:
      program arg1tst
      complex x,y,z, arg1
      x = cmplx(1.,2.)
      y = cmplx(3.,4.)
      z = arg1(x,y)
      write(*,*) z
      end

Compile arg1.f with g77 (I'm using version 3.3.5):

	g77 -c arg1.f

Compile arg1tst.f with gfortran, and link with arg1.o from above:

	gfortran arg1tst.f arg1.o -o arg1tst

Run ./arg1tst, and the result on my system is:

	Segmentation fault

Expected output is: (  4.000000    ,  6.000000    )

-- 
           Summary: COMPLEX function returns incompatible with g77
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: stevenj at fftw dot org
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


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



More information about the Gcc-bugs mailing list