public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/27046]  New: gfortran print flush in dll
@ 2006-04-05 15:31 mikko dot lyly at csc dot fi
  2006-04-05 16:02 ` [Bug fortran/27046] " pinskia at gcc dot gnu dot org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: mikko dot lyly at csc dot fi @ 2006-04-05 15:31 UTC (permalink / raw)
  To: gcc-bugs

PRINT* in gfortran 4.2.0 compiled dll's needs CALL FLUSH to perform correctly
when called from gcc (3.4.2, 3.4.5, 4.1) compiled main. Reproducible sample:

$ gfortran -shared -o ftesti.dll ftesti.f90

ftesti.f90:
-----------
subroutine print_from_gfortran(txt)
  implicit none
  character :: txt
  print *,txt
end subroutine print_from_gfortran

$ gcc -o ctesti.exe ctesti.c

ctesti.c:
---------
#include <stdio.h>
#include <windows.h>

void print_from_gcc(char* txt) {
  printf("%s\n",txt);
}

int main(int argc, char** argv) {
  HINSTANCE handle=LoadLibrary("ftesti.dll");
  FARPROC print_from_gfortran=GetProcAddress(handle,"print_from_gfortran_");

  print_from_gcc     ("c");
  print_from_gfortran("f");
  print_from_gcc     ("c");
  print_from_gfortran("f");

  return 0;
}

Now, running ctesti.exe produces

c
c
f
f

Correct output should be

c
f
c
f

Adding CALL FLUSH in ftesti.f90 fixes the case:

ftesti.f90:
-----------
subroutine print_from_gfortran(txt)
  implicit none
  character :: txt
  print *,txt
  call flush
end subroutine print_from_gfortran


-- 
           Summary: gfortran print flush in dll
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: mikko dot lyly at csc dot fi
  GCC host triplet: i686-pc-mingw32


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


^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2006-09-28 22:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-04-05 15:31 [Bug fortran/27046] New: gfortran print flush in dll mikko dot lyly at csc dot fi
2006-04-05 16:02 ` [Bug fortran/27046] " pinskia at gcc dot gnu dot org
2006-04-05 16:08 ` [Bug libfortran/27046] " pinskia at gcc dot gnu dot org
2006-04-25  6:04 ` fxcoudert at gcc dot gnu dot org
2006-05-21 14:04 ` [Bug libfortran/27046] [mingw32] " fxcoudert at gcc dot gnu dot org
2006-06-12 17:40 ` [Bug libfortran/27046] [mingw32] mixed C-Fortran I/O doesn't flush fxcoudert at gcc dot gnu dot org
2006-09-13  3:59 ` dannysmith at users dot sourceforge dot net
2006-09-13 10:10 ` dannysmith at users dot sourceforge dot net
2006-09-20  7:50 ` fxcoudert at gcc dot gnu dot org
2006-09-28 14:08 ` fxcoudert at gcc dot gnu dot org
2006-09-28 22:34 ` fxcoudert at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).