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 libfortran/113223] New: NAMELIST internal write missing leading blank character
Date: Wed, 03 Jan 2024 19:51:19 +0000	[thread overview]
Message-ID: <bug-113223-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 113223
           Summary: NAMELIST internal write missing leading blank
                    character
           Product: gcc
           Version: 14.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: kargl at gcc dot gnu.org
  Target Milestone: ---

Found at https://github.com/llvm/llvm-project/issues/76798

Program test_namelist_blank
  Integer :: i,j
  Character(300) ::s
  Namelist /nml1/i,j

  i = 99
  j = 42
  Write (s,NML=nml1)
  Write (*,'("Internal ",A)') Merge('ok ','bug',s(1:1)==' ')
  Write (*,NML=nml1)
End Program test_namelist_blank

F2018
13.11.4.3 Namelist output records
...
Except for new records created by explicit formatting within a defined
output procedure or by continuation of delimited character sequences,
each output record begins with a blank character.

Patch

diff --git a/libgfortran/io/write.c b/libgfortran/io/write.c
index f94e180ba33..a7cf5d9b233 100644
--- a/libgfortran/io/write.c
+++ b/libgfortran/io/write.c
@@ -2466,6 +2466,8 @@ namelist_write (st_parameter_dt *dtp)
        dtp->u.p.nml_delim = '\0';
     }

+  if (is_internal_unit (dtp))
+    write_character (dtp, " ", 1, 1, NODELIM);
   write_character (dtp, "&", 1, 1, NODELIM);

   /* Write namelist name in upper case - f95 std.  */

             reply	other threads:[~2024-01-03 19:51 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-03 19:51 kargl at gcc dot gnu.org [this message]
2024-01-03 19:51 ` [Bug libfortran/113223] " kargl at gcc dot gnu.org
2024-01-03 21:56 ` kargl at gcc dot gnu.org
2024-01-03 22:06 ` jvdelisle at gcc dot gnu.org
2024-01-04 16:57 ` jvdelisle at gcc dot gnu.org
2024-01-04 18:31 ` kargl at gcc dot gnu.org
2024-01-07 18:32 ` cvs-commit at gcc dot gnu.org
2024-01-13 21:02 ` cvs-commit at gcc dot gnu.org
2024-01-13 21:04 ` 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-113223-4@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).