public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libfortran/113223] New: NAMELIST internal write missing leading blank character
@ 2024-01-03 19:51 kargl at gcc dot gnu.org
  2024-01-03 19:51 ` [Bug libfortran/113223] " kargl at gcc dot gnu.org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: kargl at gcc dot gnu.org @ 2024-01-03 19:51 UTC (permalink / raw)
  To: gcc-bugs

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.  */

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

end of thread, other threads:[~2024-01-13 21:04 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-03 19:51 [Bug libfortran/113223] New: NAMELIST internal write missing leading blank character kargl at gcc dot gnu.org
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

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).