public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mikko dot lyly at csc dot fi" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/27046]  New: gfortran print flush in dll
Date: Wed, 05 Apr 2006 15:31:00 -0000	[thread overview]
Message-ID: <bug-27046-12481@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2006-04-05 15:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-05 15:31 mikko dot lyly at csc dot fi [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-27046-12481@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).