* [Bug fortran/27046] gfortran print flush in dll
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 ` pinskia at gcc dot gnu dot org
2006-04-05 16:08 ` [Bug libfortran/27046] " pinskia at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-04-05 16:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pinskia at gcc dot gnu dot org 2006-04-05 16:02 -------
*** Bug 27047 has been marked as a duplicate of this bug. ***
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27046
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/27046] gfortran print flush in dll
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 ` pinskia at gcc dot gnu dot org
2006-04-25 6:04 ` fxcoudert at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-04-05 16:08 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pinskia at gcc dot gnu dot org 2006-04-05 16:08 -------
This was fixed for the non windows case for sure.
--
pinskia at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Component|fortran |libfortran
GCC host triplet|i686-pc-mingw32 |
GCC target triplet| |i686-pc-mingw32
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27046
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/27046] gfortran print flush in dll
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
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-04-25 6:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from fxcoudert at gcc dot gnu dot org 2006-04-25 06:04 -------
(In reply to comment #2)
> This was fixed for the non windows case for sure.
Yes:
$ cat ftesti.f90
subroutine print_from_gfortran(txt)
implicit none
character :: txt
print *,txt
end subroutine print_from_gfortran
$ ./bin/gfortran -shared -o ftesti.so ftesti.f90
$ cat ctesti.c #include <stdio.h>
#include <dlfcn.h>
void print_from_gcc(char* txt) {
printf("%s\n",txt);
}
int main(int argc, char** argv) {
void * hdl = dlopen("./ftesti.so", RTLD_LAZY);
void (*print_from_gfortran)(char *) = dlsym(hdl, "print_from_gfortran_");
print_from_gcc ("c");
(*print_from_gfortran)("f");
print_from_gcc ("c");
(*print_from_gfortran)("f");
dlclose (hdl);
return 0;
}
$ gcc -o ctesti.exe ctesti.c -ldl
$ ./ctesti.exe
c
f
c
f
And this even works when libgfortran is only available as a static library (as
is the case on mingw32). I'll try to look deeper into this, but it looks very
strange...
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fxcoudert at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27046
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/27046] [mingw32] gfortran print flush in dll
2006-04-05 15:31 [Bug fortran/27046] New: gfortran print flush in dll mikko dot lyly at csc dot fi
` (2 preceding siblings ...)
2006-04-25 6:04 ` fxcoudert at gcc dot gnu dot org
@ 2006-05-21 14:04 ` 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
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-05-21 14:04 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from fxcoudert at gcc dot gnu dot org 2006-05-21 14:03 -------
Confirmed. I don't understand why, though. I'll try it harder when I have some
leisure time.
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2006-05-21 14:03:39
date| |
Summary|gfortran print flush in dll |[mingw32] gfortran print
| |flush in dll
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27046
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/27046] [mingw32] mixed C-Fortran I/O doesn't flush
2006-04-05 15:31 [Bug fortran/27046] New: gfortran print flush in dll mikko dot lyly at csc dot fi
` (3 preceding siblings ...)
2006-05-21 14:04 ` [Bug libfortran/27046] [mingw32] " fxcoudert at gcc dot gnu dot org
@ 2006-06-12 17:40 ` fxcoudert at gcc dot gnu dot org
2006-09-13 3:59 ` dannysmith at users dot sourceforge dot net
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-06-12 17:40 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from fxcoudert at gcc dot gnu dot org 2006-06-12 16:30 -------
This is not DLL-related, the following code doesn't have the expected behaviour
(although it works fine on i686-linux, even in the static case):
$ cat ctesti.c
#include <stdio.h>
void print_from_gcc(char* txt) {
printf("%s\n",txt);
}
int main(int argc, char** argv) {
print_from_gcc ("c");
print_from_gfortran_("f");
print_from_gcc ("c");
print_from_gfortran_("f");
return 0;
}
$ cat ftesti.f90
subroutine print_from_gfortran(txt)
implicit none
character :: txt
print *,txt
end subroutine print_from_gfortran
$ ../gfortran/bin/gfortran.exe ftesti.f90 ctesti.c
$ ./a.exe
c
c
f
f
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2006-05-21 14:03:39 |2006-06-12 16:30:13
date| |
Summary|[mingw32] gfortran print |[mingw32] mixed C-Fortran
|flush in dll |I/O doesn't flush
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27046
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/27046] [mingw32] mixed C-Fortran I/O doesn't flush
2006-04-05 15:31 [Bug fortran/27046] New: gfortran print flush in dll mikko dot lyly at csc dot fi
` (4 preceding siblings ...)
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
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2006-09-13 3:59 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from dannysmith at users dot sourceforge dot net 2006-09-13 03:59 -------
(In reply to comment #5)
> This is not DLL-related, the following code doesn't have the expected behaviour
> (although it works fine on i686-linux, even in the static case):
With gcc version 4.2.0 20060911, the test case in Comment #5 works as expected
if the app is run from a cmd.exe shell or from a bash shell.
When the output is redirected to a file, I get the results you report, but with
redirection, one might expect that (on windows at least) in absence of flush
call.
Danny
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27046
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/27046] [mingw32] mixed C-Fortran I/O doesn't flush
2006-04-05 15:31 [Bug fortran/27046] New: gfortran print flush in dll mikko dot lyly at csc dot fi
` (5 preceding siblings ...)
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
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: dannysmith at users dot sourceforge dot net @ 2006-09-13 10:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from dannysmith at users dot sourceforge dot net 2006-09-13 10:10 -------
(In reply to comment #5)
> This is not DLL-related, the following code doesn't have the expected behaviour
> (although it works fine on i686-linux, even in the static case):
> $ cat ctesti.c
> #include <stdio.h>
> void print_from_gcc(char* txt) {
> printf("%s\n",txt);
> }
> int main(int argc, char** argv) {
> print_from_gcc ("c");
> print_from_gfortran_("f");
> print_from_gcc ("c");
> print_from_gfortran_("f");
> return 0;
> }
Changing main() in ctesti.c to start with:
int main(int argc, char** argv) {
setvbuf(stdout, NULL, _IOLBF, 0);
fixes the redirection problem.
If you stll think that this is a libgfortran bug (I don't)
you could add
setvbuf(stdout, NULL, _IOLBF, 0);
to unix.c:output_stream() so that stdout always is line-buffered even when
!isatty(fileno(stdout))
Danny
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27046
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/27046] [mingw32] mixed C-Fortran I/O doesn't flush
2006-04-05 15:31 [Bug fortran/27046] New: gfortran print flush in dll mikko dot lyly at csc dot fi
` (6 preceding siblings ...)
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
9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-09-20 7:50 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from fxcoudert at gcc dot gnu dot org 2006-09-20 07:50 -------
(In reply to comment #7)
> If you stll think that this is a libgfortran bug (I don't)
> you could add
> setvbuf(stdout, NULL, _IOLBF, 0);
> to unix.c:output_stream() so that stdout always is line-buffered even when
> !isatty(fileno(stdout))
Indeed, I think the bug is in the user's code, but I think there's no serious
drawback to the setvbuf workaround you mention.
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Last reconfirmed|2006-06-12 16:30:13 |2006-09-20 07:50:15
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27046
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/27046] [mingw32] mixed C-Fortran I/O doesn't flush
2006-04-05 15:31 [Bug fortran/27046] New: gfortran print flush in dll mikko dot lyly at csc dot fi
` (7 preceding siblings ...)
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
9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-09-28 14:08 UTC (permalink / raw)
To: gcc-bugs
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |fxcoudert at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
Last reconfirmed|2006-09-20 07:50:15 |2006-09-28 14:08:26
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27046
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug libfortran/27046] [mingw32] mixed C-Fortran I/O doesn't flush
2006-04-05 15:31 [Bug fortran/27046] New: gfortran print flush in dll mikko dot lyly at csc dot fi
` (8 preceding siblings ...)
2006-09-28 14:08 ` fxcoudert at gcc dot gnu dot org
@ 2006-09-28 22:34 ` fxcoudert at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-09-28 22:34 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from fxcoudert at gcc dot gnu dot org 2006-09-28 22:34 -------
(In reply to comment #7)
> Changing main() in ctesti.c to start with:
> int main(int argc, char** argv) {
> setvbuf(stdout, NULL, _IOLBF, 0);
>
> fixes the redirection problem.
After some more testing, this fix doesn't work in all cases (e.g. in a shell of
MSYS window). I'm closing this PR: after all, this is not a bug in the
compiler, mixed-languages code is supposed to correctly flush both I/O systems
after operations. I would have liked to provide a workaround, only there
doesn't appear to be anythink general and robust enough.
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27046
^ permalink raw reply [flat|nested] 11+ messages in thread