When calling a C library from a gfortran-compiled program, C stdio is only
partially written.

Ability to mix languages as needed is really important in many practical
applications these days, so this would be nice to fix.  I suspect that
there is simply a missing fflush (or similar) somewhere, since the
problem appears when you have a printf with a missing newline (as in the
test case below) or when doing character-based (putc) I/O.

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, cio.c and ciotst.f, to be compiled in gcc and gfortran:

cio.c:
   #include <stdio.h>
   void cio_(void){
     printf("foo\n");
     printf("bar\n");
     printf("baz");
   }

ciotst.f:
      program ciotst
      call cio
      end

Compile:
        gcc -c cio.c
        gfortran ciotst.f cio.o -o ciotst

Run:
        ./ciotst

Output:
foo
bar

Expected output (e.g. what I get with g77):
foo
bar
baz

(Note that last line is missing a newline.)

-- 
           Summary: cannot mix C and Fortran I/O
           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=20179

Reply via email to