public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "kargl at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/109358] Wrong formatting with T-descriptor during stream output
Date: Thu, 06 Apr 2023 03:56:22 +0000	[thread overview]
Message-ID: <bug-109358-4-UEy9O1WPHI@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109358-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109358

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #3 from kargl at gcc dot gnu.org ---
(In reply to Jerry DeLisle from comment #2)
> I am using my copy of the F2018 standard.
> 
> "13.8.1.2 The Tn edit descriptor indicates that the transmission of the next
> character to or from a record is to occur at the nth character position of
> the record, relative to the left tab limit. This position can be in either
> direction from the current position."
> 
> Currently we do this:
> 
> 1234567890123
> 1234         0123
> 1234         0123
> 
> We should do this:
> 
> 1234567890123
> 1234     0123
> 1234     0123
> 
> "13.5 (3) During formatted stream output, processing of an A edit descriptor
> can cause file positioning to occur (13.7.4)."
> 
> I am not finding anything that says file positioning is not allowed.  The
> above is just elaborating different ways that an A edit descriptor affects
> the positioning.  Positioning is always done no matter what with the T
> specifier.
> 
> Regardless, I do need to fix this.

Yes, there is a bug.  The A edit descriptor and whether or not it does
file positioning is not relevant.  The relevant words from F2018 are

   13.8.1.2 T, TL, and TR editing

   The left tab limit affects file positioning by the T and TL edit
   descriptors. Immediately prior to nonchild data transfer (12.6.4.8.3),
   the left tab limit becomes defined as the character position of the
   current record or the current position of the stream file.  If, during
   data transfer, the file is positioned to another record, the left tab
   limit becomes defined as character position one of that record.

with

  write(fd, "(a)") "1234567890123"
  write(fd, "(a, t10, a)") "1234", "0123"  ! A-descriptor, file positioning 

the left tab limit for the 2nd write is established before data
transfer to position 1.  The 'T10' edit descriptor is relative to
that position.  The write of "1234" in the 2nd write might place
the character position to 5, but it does not update the left tab
limit because the write() is not positioned to a new record.

  parent reply	other threads:[~2023-04-06  3:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-31 10:49 [Bug fortran/109358] New: " baradi09 at gmail dot com
2023-03-31 20:27 ` [Bug fortran/109358] " jvdelisle at gcc dot gnu.org
2023-04-06  2:48 ` jvdelisle at gcc dot gnu.org
2023-04-06  3:56 ` kargl at gcc dot gnu.org [this message]
2023-04-15  3:31 ` jvdelisle at gcc dot gnu.org
2023-04-16  8:18 ` baradi09 at gmail dot com
2023-06-02  1:51 ` jvdelisle at gcc dot gnu.org
2023-06-02  5:17 ` sgk at troutmask dot apl.washington.edu
2024-02-03 18:28 ` jvdelisle at gcc dot gnu.org
2024-02-08 18:14 ` jvdelisle at gcc dot gnu.org
2024-02-08 18:17 ` jvdelisle at gcc dot gnu.org
2024-02-12 20:05 ` jvdelisle at gcc dot gnu.org
2024-02-12 23:30 ` cvs-commit at gcc dot gnu.org
2024-02-13  3:26 ` cvs-commit at gcc dot gnu.org
2024-02-14 19:58 ` jvdelisle at gcc dot gnu.org
2024-02-17 20:16 ` anlauf at gcc dot gnu.org
2024-02-19  2:38 ` jvdelisle at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-109358-4-UEy9O1WPHI@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).