Bug 25349 - T edit descriptor broken for output on files
Summary: T edit descriptor broken for output on files
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: Not yet assigned to anyone
URL:
Keywords: wrong-code
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2005-12-11 09:02 UTC by Thomas Koenig
Modified: 2006-01-01 05:27 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.0.3 4.1.0 4.2.0
Last reconfirmed: 2005-12-11 13:59:18


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Koenig 2005-12-11 09:02:27 UTC
$ cat t.f
      program main
      character(len=10) line
      write (*,'(1X,A,T1,A)') 'A','B'
      write (line,'(1X,A,T1,A)') 'A','B'
      print '(A)',line
      end
$ gfortran t.f
$ ./a.out
B
BA
$ 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 20051204 (experimental)
$ g77 t.f
$ ./a.out
BA
BA
Comment 1 Francois-Xavier Coudert 2005-12-11 10:20:20 UTC
I *hate* T format descriptors. And I thought we had this topic working and covered by the testsuite.

This is not a regression, though, since 4.0.3 segfaults on this same example.
Comment 2 Thomas Koenig 2005-12-11 10:57:17 UTC
(In reply to comment #1)
> I *hate* T format descriptors. And I thought we had this topic working and
> covered by the testsuite.

The testsuite often uses internal writes.  I just converted tl_editing.f90
to use external instead of internal I/O, and it failed, as well.

> This is not a regression, though, since 4.0.3 segfaults on this same example.

It does work with g77.  Why did you remove PR 19292?
Comment 3 Francois-Xavier Coudert 2005-12-11 12:51:46 UTC
(In reply to comment #2)
> It does work with g77.  Why did you remove PR 19292?

Sorry, must have been a wrong keypress, didn't mean to do it.

Another thing. I updated my tree (Thomas' convert patch got in) and this changed the problem:
$ cat t.f 
      write (*,'(1X,A,T1,A)') 'A','B'
      end
$ gfortran t.f && ./a.out
At line 1 of file t.f
Fortran runtime error: End of record

Does someone else see this?
Comment 4 Francois-Xavier Coudert 2005-12-11 13:59:18 UTC
(In reply to comment #3)
> Does someone else see this?

Answering to myself: it disappeared with a clean build.

As for the cause of the problem, it's truncation after the last character write. Another slightly different example:

$ cat t.f 
      open(11,status="replace")
      write (11,'(A,TL2,A)') 'AA','B'
      end
$ gfortran t.f && ./a.out
$ cat fort.11 
B
Comment 5 Jerry DeLisle 2005-12-11 17:54:10 UTC
This is simialr to pr25264.  I had to fix a regression in tl-editing, so maybe i need to extend that to the regular files.  I was beginning to wonder why internal units seemed so different fromn files.  Perhaps the underlying bug in files, if fixed, will bring some of this code back into uniformity.

Comment 6 Jerry DeLisle 2005-12-16 09:04:53 UTC
Patch submitted for review and approval.
Comment 7 Jerry DeLisle 2005-12-16 19:32:27 UTC
Subject: Bug 25349

Author: jvdelisle
Date: Fri Dec 16 19:32:21 2005
New Revision: 108671

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108671
Log:
2005-12-16  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/25264
	PR libgfortran/25349
	* io/unit.c (get_unit): Delete code that cleared the string when the
	unit was opened, which is too soon.
	* io/transfer.c (next_record_w): Pass done flag in.  Change logic for
	setting max_pos.  Add code to position unit and pad record as needed.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/transfer.c
    trunk/libgfortran/io/unit.c

Comment 8 Jerry DeLisle 2005-12-16 19:40:42 UTC
Subject: Bug 25349

Author: jvdelisle
Date: Fri Dec 16 19:40:36 2005
New Revision: 108673

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108673
Log:
2005-12-16  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/25264
	PR libgfortran/25349
	* gfortran.dg/tl_editing.f90: Added additional checks.
	* gfortran.dg/t_editing.f: New test.
	* gfortran.dg/write_padding.f90: New test

Added:
    trunk/gcc/testsuite/gfortran.dg/t_editing.f
    trunk/gcc/testsuite/gfortran.dg/write_padding.f90
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/tl_editing.f90

Comment 9 Jerry DeLisle 2005-12-18 08:24:12 UTC
Subject: Bug 25349

Author: jvdelisle
Date: Sun Dec 18 08:24:04 2005
New Revision: 108744

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108744
Log:
2005-12-17  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/25264
	PR libgfortran/25349
	* io/unit.c (get_unit): Delete code that cleared the string when the
	unit was opened, which is too soon.
	* io/transfer.c (next_record_w): Pass done flag in.  Change logic for
	setting max_pos.  Add code to position unit and pad record as needed.

Modified:
    branches/gcc-4_1-branch/libgfortran/ChangeLog
    branches/gcc-4_1-branch/libgfortran/io/transfer.c
    branches/gcc-4_1-branch/libgfortran/io/unit.c

Comment 10 Jerry DeLisle 2005-12-18 08:32:14 UTC
Subject: Bug 25349

Author: jvdelisle
Date: Sun Dec 18 08:32:09 2005
New Revision: 108745

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108745
Log:
2005-12-17  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR libgfortran/25264
	PR libgfortran/25349
	* gfortran.dg/tl_editing.f90: Added additional checks.
	* gfortran.dg/t_editing.f: New test.
	* gfortran.dg/write_padding.f90: New test

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/t_editing.f
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/write_padding.f90
Modified:
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/tl_editing.f90

Comment 11 Jerry DeLisle 2005-12-19 07:23:17 UTC
Fixed in 4.1 and 4.2