$ cat advance.f90 program main write (*,'(A)',advance="no") 'ab' write (*,'(T1,A)') 'c' end $ gfortran advance.f90 $ ./a.out ab$ gfortran -v Using built-in specs. Target: i686-pc-linux-gnu Configured with: ../../gcc/trunk/configure --prefix=/home/ig25 --enable-languages=c,fortran Thread model: posix gcc version 4.2.0 20051214 (experimental) The output should be abc (see Richard Maine's posting, <1h7pi1z.dwx39giomozkN%nospam@see.signature>).
This simple patch appears to fix this: The stement moved needs to be executed before the return is called. =================================================================== *** io/transfer.c (revision 108671) --- io/transfer.c (working copy) *************** finalize_transfer (st_parameter_dt *dtp) *** 2017,2022 **** --- 2017,2023 ---- finish_list_read (dtp); else { + dtp->u.p.current_unit->current_record = 0; if (dtp->u.p.advance_status == ADVANCE_NO || dtp->u.p.seen_dollar) { /* Most systems buffer lines, so force the partial record *************** finalize_transfer (st_parameter_dt *dtp) *** 2027,2033 **** } next_record (dtp, 1); - dtp->u.p.current_unit->current_record = 0; } sfree (dtp->u.p.current_unit->s); --- 2028,2033 ----
(In reply to comment #1) > This simple patch appears to fix this: The stement moved needs to be executed > before the return is called. Yep, this fixes the test case, and doesn't break anything else (at least nothing that I tried). Looks good.
Subject: Bug 25463 Author: jvdelisle Date: Mon Dec 19 06:52:33 2005 New Revision: 108784 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108784 Log: 2005-12-18 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/25463 * io/transfer.c (finalize_transfer): Fix execution order so that next_record is set to zero in all cases. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/transfer.c
Subject: Bug 25463 Author: jvdelisle Date: Mon Dec 19 07:02:05 2005 New Revision: 108785 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108785 Log: 2005-12-18 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/25463 * gfortran.dg/advance.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/advance.f90 Modified: trunk/gcc/testsuite/ChangeLog
Commited to 4.2 Will commit to 4.1 in ~24 hours.
Subject: Bug 25463 Author: jvdelisle Date: Wed Dec 21 04:50:19 2005 New Revision: 108896 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108896 Log: 2005-12-20 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/25463 * io/transfer.c (finalize_transfer): Fix execution order so that next_record is set to zero in all cases. Modified: branches/gcc-4_1-branch/libgfortran/ChangeLog branches/gcc-4_1-branch/libgfortran/io/transfer.c
Subject: Bug 25463 Author: jvdelisle Date: Wed Dec 21 05:08:53 2005 New Revision: 108897 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108897 Log: 2005-12-20 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libgfortran/25463 * gfortran.dg/advance.f90: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/advance.f90 Modified: branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
Fixed on 4.1 and 4.2