public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/31199]  New: wrong code generated with gfortran
@ 2007-03-16 11:26 jv244 at cam dot ac dot uk
  2007-03-16 13:54 ` [Bug fortran/31199] write with "t1" format gives wrong output burnus at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 14+ messages in thread
From: jv244 at cam dot ac dot uk @ 2007-03-16 11:26 UTC (permalink / raw)
  To: gcc-bugs

With a recent gfortran, the following compiles, but generates the wrong
results:

       program write_write
       character(len=20) :: a,b,c
       write (10,"(a,t1,a,a)") "XXXXXXXXX", "ABC", "DEF"
       write (10,"(a,t1,a)",advance='no') "XXXXXXXXX", "ABC"
       write (10,"(a)") "DEF"
       write (10,"(a)") "ABCDEFXXX"
       REWIND(10)
       read(10,*) a
       read(10,*) b
       read(10,*) c
       IF (a.NE.b) CALL ABORT()
       IF (a.NE.c) CALL ABORT()
       end


-- 
           Summary: wrong code generated with gfortran
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jv244 at cam dot ac dot uk


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
@ 2007-03-16 13:54 ` burnus at gcc dot gnu dot org
  2007-03-16 22:57 ` jvdelisle at gcc dot gnu dot org
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-16 13:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from burnus at gcc dot gnu dot org  2007-03-16 13:54 -------
Current result:
 a = ABCDEFXXX
 b = ABCDEF
 c = ABCDEFXXX
Expected (g95/ifort):
 ABCDEFXXX
 ABCDEFXXX
 ABCDEFXXX
(NAG f95 has:
 ABCDEFXXX
 ABCXXXXXXDEF
 ABCDEFXXX
)


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jvdelisle at gcc dot gnu dot
                   |                            |org, burnus at gcc dot gnu
                   |                            |dot org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2007-03-16 13:54:17
               date|                            |
            Summary|wrong code generated with   |write with "t1" format gives
                   |gfortran                    |wrong output


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
  2007-03-16 13:54 ` [Bug fortran/31199] write with "t1" format gives wrong output burnus at gcc dot gnu dot org
@ 2007-03-16 22:57 ` jvdelisle at gcc dot gnu dot org
  2007-03-17 16:00 ` jvdelisle at gcc dot gnu dot org
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-03-16 22:57 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from jvdelisle at gcc dot gnu dot org  2007-03-16 22:57 -------
I will work this one.  I want to review the standard.  I think we are
truncating and I am not so sure this has to do with the t1 format specifier. 
We'll see.  


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jvdelisle at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2007-03-16 13:54:17         |2007-03-16 22:57:08
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
  2007-03-16 13:54 ` [Bug fortran/31199] write with "t1" format gives wrong output burnus at gcc dot gnu dot org
  2007-03-16 22:57 ` jvdelisle at gcc dot gnu dot org
@ 2007-03-17 16:00 ` jvdelisle at gcc dot gnu dot org
  2007-03-19  5:50 ` jvdelisle at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-03-17 16:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from jvdelisle at gcc dot gnu dot org  2007-03-17 15:59 -------
*** Bug 31207 has been marked as a duplicate of this bug. ***


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (2 preceding siblings ...)
  2007-03-17 16:00 ` jvdelisle at gcc dot gnu dot org
@ 2007-03-19  5:50 ` jvdelisle at gcc dot gnu dot org
  2007-03-19 11:12 ` burnus at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-03-19  5:50 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from jvdelisle at gcc dot gnu dot org  2007-03-19 05:49 -------
Found it.  In the case of advance="no" we are not saving the maximum position
reached to be used by the following write statement.  This one is subtle.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (3 preceding siblings ...)
  2007-03-19  5:50 ` jvdelisle at gcc dot gnu dot org
@ 2007-03-19 11:12 ` burnus at gcc dot gnu dot org
  2007-03-19 12:15 ` dominiq at lps dot ens dot fr
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-19 11:12 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from burnus at gcc dot gnu dot org  2007-03-19 11:12 -------
Current result:
 a = ABCDEFXXX
 b = ABCDEF
 c = ABCDEFXXX

Result by g95/ifort:
 ABCDEFXXX
 ABCDEFXXX
 ABCDEFXXX

Result by NAG f95, SUN and HP:
 ABCDEFXXX
 ABCXXXXXXDEF
 ABCDEFXXX

I think the latter is correct:

Section 9.2.3.3 of the Fortran 2003 standard:
"For a formatted stream output statement, ... the terminal point of
the file is set to the highest-numbered position to which data was
transferred by the statement."

(Thanks to Ian Hounam/NAG for pointing out.)


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (4 preceding siblings ...)
  2007-03-19 11:12 ` burnus at gcc dot gnu dot org
@ 2007-03-19 12:15 ` dominiq at lps dot ens dot fr
  2007-03-19 12:18 ` dominiq at lps dot ens dot fr
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: dominiq at lps dot ens dot fr @ 2007-03-19 12:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from dominiq at lps dot ens dot fr  2007-03-19 12:15 -------
> Result by g95/ifort:

You can probably add xlf to this list (should be checked
on a recent version).


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (5 preceding siblings ...)
  2007-03-19 12:15 ` dominiq at lps dot ens dot fr
@ 2007-03-19 12:18 ` dominiq at lps dot ens dot fr
  2007-03-19 12:53 ` [Bug fortran/31199] write with "t1" + nonadvancing transfer " burnus at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: dominiq at lps dot ens dot fr @ 2007-03-19 12:18 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from dominiq at lps dot ens dot fr  2007-03-19 12:18 -------
> You can probably add xlf to this list

and Portland Group Fortran.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" + nonadvancing transfer format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (6 preceding siblings ...)
  2007-03-19 12:18 ` dominiq at lps dot ens dot fr
@ 2007-03-19 12:53 ` burnus at gcc dot gnu dot org
  2007-03-20  0:41 ` jvdelisle at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-19 12:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from burnus at gcc dot gnu dot org  2007-03-19 12:53 -------
Reading further, I find:
"For nonadvancing input [...] If no error condition occurred in a nonadvancing
output statement, the file position is not changed."

If I understand the whole correctly, it means:
- The position for the nonadvancing transfer of "XXXXXXXXX", t1, "ABC" is after
the "ABC".
- After doing the advancing transfer "DEF" it is at the highest-numbered
position to which data was transferred by the statement, namely after
"ABCDEFXXX" + new_line.

Thus, NAG f95/Sun/HP seems to be wrong; ifort, g95, xlf and portland seem to be
right and gfortran gets it differently wrong.


-- 

burnus at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|write with "t1" format gives|write with "t1" +
                   |wrong output                |nonadvancing transfer format
                   |                            |gives wrong output


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" + nonadvancing transfer format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (7 preceding siblings ...)
  2007-03-19 12:53 ` [Bug fortran/31199] write with "t1" + nonadvancing transfer " burnus at gcc dot gnu dot org
@ 2007-03-20  0:41 ` jvdelisle at gcc dot gnu dot org
  2007-03-23 16:20 ` patchapp at dberlin dot org
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-03-20  0:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from jvdelisle at gcc dot gnu dot org  2007-03-20 00:41 -------
Reply to comment #8: that was my take on this, that ifort is correct.  It
passed my intuitive sense of it.  Non-advancing means what it says so that the
subsequent write must continue from there and overwrite what was previously
written.  Then,  bytes written already after that are still there and define
the end of the record/line.

Regardless, I am close to a fix.  I will post to list in the next day or so. 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" + nonadvancing transfer format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (8 preceding siblings ...)
  2007-03-20  0:41 ` jvdelisle at gcc dot gnu dot org
@ 2007-03-23 16:20 ` patchapp at dberlin dot org
  2007-03-26  3:23 ` jvdelisle at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 14+ messages in thread
From: patchapp at dberlin dot org @ 2007-03-23 16:20 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from patchapp at dberlin dot org  2007-03-23 16:20 -------
Subject: Bug number PR31199

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-03/msg01554.html


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" + nonadvancing transfer format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (9 preceding siblings ...)
  2007-03-23 16:20 ` patchapp at dberlin dot org
@ 2007-03-26  3:23 ` jvdelisle at gcc dot gnu dot org
  2007-03-26  3:41 ` jvdelisle at gcc dot gnu dot org
  2007-03-28  0:48 ` jvdelisle at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-03-26  3:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #11 from jvdelisle at gcc dot gnu dot org  2007-03-26 04:23 -------
Subject: Bug 31199

Author: jvdelisle
Date: Mon Mar 26 04:23:15 2007
New Revision: 123205

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123205
Log:
2007-03-25  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libgfortran/31199
        *io/io.h: Add saved_pos to gfc_unit structure.
        *io/open.c (new_unit): Initialize saved_pos.
        *io/transfer.c (data_transfer_init): Set max_pos to value in saved_pos.
        (next_record_w): Fix whitespace.
        (finalze_transfer): Calculate max_pos for ADVANCE="no" and save it for
        later use.  If not ADVANCE="no" set saved_pos to zero.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/io.h
    trunk/libgfortran/io/open.c
    trunk/libgfortran/io/transfer.c


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" + nonadvancing transfer format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (10 preceding siblings ...)
  2007-03-26  3:23 ` jvdelisle at gcc dot gnu dot org
@ 2007-03-26  3:41 ` jvdelisle at gcc dot gnu dot org
  2007-03-28  0:48 ` jvdelisle at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-03-26  3:41 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #12 from jvdelisle at gcc dot gnu dot org  2007-03-26 04:41 -------
Subject: Bug 31199

Author: jvdelisle
Date: Mon Mar 26 04:41:29 2007
New Revision: 123207

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=123207
Log:
2007-03-25  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

        PR libgfortran/31199
        * gfortran.dg/fmt_t_4.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/fmt_t_4.f90
Modified:
    trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

* [Bug fortran/31199] write with "t1" + nonadvancing transfer format gives wrong output
  2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
                   ` (11 preceding siblings ...)
  2007-03-26  3:41 ` jvdelisle at gcc dot gnu dot org
@ 2007-03-28  0:48 ` jvdelisle at gcc dot gnu dot org
  12 siblings, 0 replies; 14+ messages in thread
From: jvdelisle at gcc dot gnu dot org @ 2007-03-28  0:48 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #13 from jvdelisle at gcc dot gnu dot org  2007-03-28 01:48 -------
Not a regression, closing.


-- 

jvdelisle at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31199


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2007-03-28  0:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-16 11:26 [Bug fortran/31199] New: wrong code generated with gfortran jv244 at cam dot ac dot uk
2007-03-16 13:54 ` [Bug fortran/31199] write with "t1" format gives wrong output burnus at gcc dot gnu dot org
2007-03-16 22:57 ` jvdelisle at gcc dot gnu dot org
2007-03-17 16:00 ` jvdelisle at gcc dot gnu dot org
2007-03-19  5:50 ` jvdelisle at gcc dot gnu dot org
2007-03-19 11:12 ` burnus at gcc dot gnu dot org
2007-03-19 12:15 ` dominiq at lps dot ens dot fr
2007-03-19 12:18 ` dominiq at lps dot ens dot fr
2007-03-19 12:53 ` [Bug fortran/31199] write with "t1" + nonadvancing transfer " burnus at gcc dot gnu dot org
2007-03-20  0:41 ` jvdelisle at gcc dot gnu dot org
2007-03-23 16:20 ` patchapp at dberlin dot org
2007-03-26  3:23 ` jvdelisle at gcc dot gnu dot org
2007-03-26  3:41 ` jvdelisle at gcc dot gnu dot org
2007-03-28  0:48 ` jvdelisle at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).