[Bug libfortran/39664] [4.5 Regression] Revision 145571 breaks stdio
--- Comment #16 from jvdelisle at gcc dot gnu dot org 2009-05-27 01:22 --- Subject: Bug 39664 Author: jvdelisle Date: Wed May 27 01:21:22 2009 New Revision: 147887 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=147887 Log: 2009-05-23 Jerry DeLisle jvdeli...@gcc.gnu.org Backport from mainline: PR libfortran/37754 * io/write_float.def: Simplify format calculation. 2009-05-23 Francois-Xavier Coudert fxcoud...@gcc.gnu.org Backport from mainline: PR fortran/22423 * io/transfer.c (read_block_direct): Avoid warning. 2009-05-23 Janne Blomqvist j...@gcc.gnu.org Backport from mainline: PR libfortran/39667 * io/file_pos.c (st_rewind): Don't truncate or flush. * io/intrinsics.c (fgetc): Flush if switching mode. (fputc): Likewise. 2009-05-23 Janne Blomqvist j...@gcc.gnu.org Backport from mainline: PR libfortran/39782 * io/transfer.c (data_transfer_init): Don't flush before seek. 2009-05-23 Janne Blomqvist j...@gcc.gnu.org Backport from mainline: * io/io.h (is_preconnected): Remove prototype. * io/unix.c (is_preconnected): Remove function. 2009-05-23 Janne Blomqvist j...@gcc.gnu.org Backport from mainline: PR libfortran/38668 * io/transfer.c (finalize_transfer): Don't flush for advance='no'. 2009-05-23 Danny Smith dannysm...@clear.net.nz Backport from mainline: * io/write.c (itoa) : Rename back to gfc_itoa. (write_i): Adjust call to write_decimal. (write_integer): Use gfc_itoa. 2009-05-23 Janne Blomqvist j...@gcc.gnu.org Backport from mainline: * io/io.h (move_pos_offset): Remove prototype. * io/transfer.c (formatted_transfer_scalar_read): Use sseek instead of move_pos_offset. * io/unix.c (move_pos_offset): Remove. 2009-05-23 Janne Blomqvist j...@gcc.gnu.org Backport from mainline: PR libfortran/39665 libfortran/39702 libfortran/39709 * io/io.h (st_parameter_dt): Revert aligned attribute from u.p.value. * io/list_read.c (read_complex): Read directly into user pointer. (read_real): Likewise. (list_formatted_read_scalar): Update read_complex and read_real calls. (nml_read_obj): Read directly into user pointer. 2009-05-23 Janne Blomqvist j...@gcc.gnu.org Backport from mainline: PR libfortran/39665 * io/io.h (st_parameter_dt): Add aligned attribute to u.p.value. * io/read.c (convert_real): Add note about alignment requirements. 2009-05-23 Janne Blomqvist j...@gcc.gnu.org Backport from mainline: * io/open.c (already_open): Test for POSIX close return value. * io/unit.c (close_unit_1): Likewise. * io/unix.c (raw_close): Return 0 for success for preconnected units. 2009-05-23 Janne Blomqvist j...@gcc.gnu.org Backport from mainline: * runtime/error.c (gfc_itoa): Move to io/write.c (xtoa): Rename to gfc_xtoa. * runtime/backtrace.c (show_backtrace): Call gfc_xtoa. * libgfortran.h (gfc_itoa): Remove prototype. (xtoa): Rename prototype to gfc_xtoa. * io/list_read.c (nml_read_obj): Use size_t for string length. * io/transfer.c (read_block_direct): Change nbytes arg from pointer to value. (unformatted_read): Minor cleanup, call read_block_directly properly. (skip_record): Use ssize_t. (next_record_w_unf): Avoid stell() call by calling sseek with SEEK_CUR. (iolength_transfer): Make sure to multiply before cast. * io/intrinsics.c (fgetc): Remove unnecessary variable. * io/format.c (format_hash): Use gfc_charlen_type. * io/write.c (itoa): Move from runtime/error.c:gfc_itoa, rename, make static. (write_i): Call with pointer to itoa. (write_z): Call with pointer to gfc_xtoa. (write_integer): Pointer to itoa. (nml_write_obj): Type cleanup, don't call strlen in loop. 2009-05-23 H.J. Lu hongjiu...@intel.com Backport from mainline: PR libgfortran/39664 * io/unix.c (raw_close): Don't close STDOUT_FILENO, STDERR_FILENO nor STDIN_FILENO. 2009-05-23 David Edelsohn edels...@gnu.org Backport from mainline: * io/io.h (struct stream): Rename truncate to trunc. (struncate): Same. * io/unix.c (raw_init): Rename truncate to trunc. (buf_init): Same. (open_internal): Same. 2009-05-23 Daniel Kraft d...@domob.eu Backport from mainline: PR fortran/38654 * io/read.c (read_f): Reworked to speed up floating point parsing. (convert_real): Use pointer-casting instead of memcpy and temporaries. 2009-05-23 Jerry DeLisle jvdeli...@gcc.gnu.org Backport from mainline: PR libfortran/37754 * io/io.h (format_hash_entry): New structure for hash
[Bug libfortran/39664] [4.5 Regression] Revision 145571 breaks stdio
--- Comment #6 from hjl dot tools at gmail dot com 2009-04-06 22:20 --- Revision 145571 breaks stdio when the output was redirected to a file: [h[...@gnu-16 pr39664]$ cat foo.c #include stdio.h int main () { printf(\n); printf(Done.\n); return 0; } j...@gnu-16 pr39664]$ /export/gnu/import/rrs/145571/usr/bin/gcc -O2 -c -o foo.o foo.c [...@gnu-16 pr39664]$ /export/gnu/import/rrs/145571/usr/bin/gfortran -o foo foo.o [...@gnu-16 pr39664]$ LD_LIBRARY_PATH=/export/gnu/import/rrs/145571/usr/lib64 ./foo 1 [...@gnu-16 pr39664]$ cat 1 [...@gnu-16 pr39664]$ LD_LIBRARY_PATH=/export/gnu/import/rrs/145571/usr/lib64 ./foo Done. [...@gnu-16 pr39664]$ -- hjl dot tools at gmail dot com changed: What|Removed |Added Summary|[4.5 Regression] Revision |[4.5 Regression] Revision |145571 caused 436.cactusADM |145571 breaks stdio |in SPEC CPU 2006 to fail| http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39664
[Bug libfortran/39664] [4.5 Regression] Revision 145571 breaks stdio
--- Comment #7 from pinskia at gcc dot gnu dot org 2009-04-06 22:22 --- I don't know if this is really a bug. The interaction between Fortran I/O and C FILE I/O is not defined anywhere. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39664
[Bug libfortran/39664] [4.5 Regression] Revision 145571 breaks stdio
--- Comment #8 from hjl dot tools at gmail dot com 2009-04-06 22:41 --- (In reply to comment #7) I don't know if this is really a bug. The interaction between Fortran I/O and C FILE I/O is not defined anywhere. Does it mean that gcc doesn't support mixing C codes which contain stdio with Fortran I/O? -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39664
[Bug libfortran/39664] [4.5 Regression] Revision 145571 breaks stdio
--- Comment #9 from hjl dot tools at gmail dot com 2009-04-06 22:43 --- This patch seems to work for the small testcase: Index: io/unix.c === --- io/unix.c (revision 145571) +++ io/unix.c (working copy) @@ -344,7 +344,12 @@ raw_close (unix_stream * s) { int retval; - retval = close (s-fd); + if (s-fd != STDOUT_FILENO + s-fd != STDERR_FILENO + s-fd != STDIN_FILENO) +retval = close (s-fd); + else +retval = SUCCESS; free_mem (s); return retval; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39664
[Bug libfortran/39664] [4.5 Regression] Revision 145571 breaks stdio
--- Comment #10 from kargl at gcc dot gnu dot org 2009-04-06 22:46 --- (In reply to comment #6) Revision 145571 breaks stdio when the output was redirected to a file: [h[...@gnu-16 pr39664]$ cat foo.c #include stdio.h int main () { printf(\n); printf(Done.\n); return 0; } j...@gnu-16 pr39664]$ /export/gnu/import/rrs/145571/usr/bin/gcc -O2 -c -o foo.o foo.c [...@gnu-16 pr39664]$ /export/gnu/import/rrs/145571/usr/bin/gfortran -o foo foo.o [...@gnu-16 pr39664]$ LD_LIBRARY_PATH=/export/gnu/import/rrs/145571/usr/lib64 ./foo 1 [...@gnu-16 pr39664]$ cat 1 [...@gnu-16 pr39664]$ LD_LIBRARY_PATH=/export/gnu/import/rrs/145571/usr/lib64 ./foo Done. [...@gnu-16 pr39664]$ Works for me. troutmask:sgk[204] ~/work/4x/bin/gcc -c g.c troutmask:sgk[205] gfc4x -o z g.o troutmask:sgk[206] ./z zxc troutmask:sgk[207] cat zxc Done. troutmask:sgk[208] gfc4x --version GNU Fortran (GCC) 4.5.0 20090406 (experimental) -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39664
[Bug libfortran/39664] [4.5 Regression] Revision 145571 breaks stdio
--- Comment #11 from pinskia at gcc dot gnu dot org 2009-04-06 22:47 --- (In reply to comment #9) This patch seems to work for the small testcase: This patch looks correct based on the old code: - if (s-fd != STDOUT_FILENO s-fd != STDERR_FILENO s-fd != STDIN_FILENO) -{ - if (close (s-fd) 0) - return FAILURE; -} - -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39664
[Bug libfortran/39664] [4.5 Regression] Revision 145571 breaks stdio
--- Comment #12 from hjl dot tools at gmail dot com 2009-04-06 22:53 --- A patch is posted at http://gcc.gnu.org/ml/gcc-patches/2009-04/msg00464.html -- hjl dot tools at gmail dot com changed: What|Removed |Added URL||http://gcc.gnu.org/ml/gcc- ||patches/2009- ||04/msg00464.html http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39664
[Bug libfortran/39664] [4.5 Regression] Revision 145571 breaks stdio
--- Comment #13 from hjl dot tools at gmail dot com 2009-04-06 22:57 --- (In reply to comment #10) Works for me. troutmask:sgk[204] ~/work/4x/bin/gcc -c g.c troutmask:sgk[205] gfc4x -o z g.o troutmask:sgk[206] ./z zxc troutmask:sgk[207] cat zxc Done. Did you try it on Linux? libgfortran closes FDs which are the parts of C library. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39664
[Bug libfortran/39664] [4.5 Regression] Revision 145571 breaks stdio
--- Comment #14 from hjl at gcc dot gnu dot org 2009-04-06 23:08 --- Subject: Bug 39664 Author: hjl Date: Mon Apr 6 23:07:51 2009 New Revision: 145636 URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=145636 Log: 2009-04-06 H.J. Lu hongjiu...@intel.com PR libgfortran/39664 * io/unix.c (raw_close): Don't close STDOUT_FILENO, STDERR_FILENO nor STDIN_FILENO. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/unix.c -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39664
[Bug libfortran/39664] [4.5 Regression] Revision 145571 breaks stdio
--- Comment #15 from hjl dot tools at gmail dot com 2009-04-06 23:16 --- Fixed. -- hjl dot tools at gmail dot com changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution||FIXED Target Milestone|--- |4.5.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39664