Bug 25463 - T edit descriptor and ADVANCE="no"
Summary: T edit descriptor and ADVANCE="no"
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.1.0
Assignee: Jerry DeLisle
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2005-12-17 17:45 UTC by Thomas Koenig
Modified: 2006-01-01 05:30 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-12-17 21:33:29


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2005-12-17 17:45:43 UTC
$ 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>).
Comment 1 Jerry DeLisle 2005-12-17 21:33:29 UTC
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 ----
Comment 2 Thomas Koenig 2005-12-17 22:23:01 UTC
(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.
Comment 3 Jerry DeLisle 2005-12-19 06:52:41 UTC
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

Comment 4 Jerry DeLisle 2005-12-19 07:02:12 UTC
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

Comment 5 Jerry DeLisle 2005-12-19 07:03:25 UTC
Commited to 4.2  Will commit to 4.1 in ~24 hours.
Comment 6 Jerry DeLisle 2005-12-21 04:50:22 UTC
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

Comment 7 Jerry DeLisle 2005-12-21 05:09:00 UTC
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

Comment 8 Jerry DeLisle 2005-12-23 05:57:57 UTC
Fixed on 4.1 and 4.2