Reading back a namelist string which contains an apostrophe doesn't work. I am marking this as an enhancement because reading back what we wrote with a namelist isn't guaranteed to work (see note 10.37 in the working draft). It does work with ifort, for example. $ cat namelist.f90 program main implicit none character(len=3) :: a namelist /foo/ a open(10,status="scratch") a = "a'a" write(10,foo) write (*,foo) rewind 10 read (10,foo) end program main $ gfortran namelist.f90 $ ./a.out &FOO A=a'a, / At line 10 of file namelist.f90 (unit = 10, file = '/tmp/gfortrantmpy3HLPb') Fortran runtime error: Cannot match namelist object name a'a,
(In reply to comment #0) > It does work with ifort, for example. I works with g95, but fails with xlf, unless I add an delim='apostrophe' to the open statement. I the latter case gfortran still fails, so this might be a bug.
(In reply to comment #1) If I replace the open by: open(10,delim='apostrophe') then the file fort.10 contains after the crash: % cat fort.10 &FOO A='a'a', / This looks like a quoting bug. Jerry?
I want to study this a bit. I think it is a bug.
Subject: Bug number PR33253 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-09/msg00153.html
Subject: Bug 33253 Author: jvdelisle Date: Mon Sep 3 19:27:48 2007 New Revision: 128056 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128056 Log: 2007-09-03 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR fortran/33253 * gfortran.dg/namelist_15.f90: Update test. * gfortran.dg/namelist_24.f90: Update test. * gfortran.dg/namelist_38.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/namelist_38.f90 Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/namelist_15.f90 trunk/gcc/testsuite/gfortran.dg/namelist_24.f90
Subject: Bug 33253 Author: jvdelisle Date: Mon Sep 3 19:29:17 2007 New Revision: 128057 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128057 Log: 2007-09-03 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libfortran/33253 * io/list_read.c (read_character): Use DELIM_APOSTROPHE and DELIM_QUOTE in check of first character in string. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/list_read.c
Fixed on trunk.
Subject: Bug 33253 Author: jvdelisle Date: Thu Sep 6 01:20:02 2007 New Revision: 128170 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128170 Log: 2007-09-05 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libfortran/33253 * io/write.c (nml_write_obj): Set the delimiter correctly before calling write_character. (namelist_write): Clean up the code a little and add comments to clarify what its doing. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/write.c
Subject: Bug 33253 Author: jvdelisle Date: Thu Sep 6 01:24:17 2007 New Revision: 128171 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128171 Log: 2007-09-06 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libfortran/33253 * gfortran.dg/namelist_38.f90: Update test for DELIM= . Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/namelist_38.f90
Reverted the patch to close pr33421. Reopening this to find the right solution.
It turns out that the original patch for this bug is probably what we want. Unfortunately it uncovers a nasty latent bug where an extraneous namelist read is attempted. It only seems to occur with multiple levels of derived types. For example: &MYNML x(2)%m(1)%ch(2) ='q', , &end Will read correctly with the initial patch for the bug here if the extra comma is placed at the end. This is a bugger since it involves both recursive calls and incrementing of loop specs all within a do - while loop. Still working on it. :)
Subject: Bug 33253 Author: jvdelisle Date: Wed Oct 3 00:33:09 2007 New Revision: 128973 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128973 Log: 2007-10-02 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libfortran/33253 * io/list_read.c (read_character): Use DELIM_APOSTROPHE and DELIM_QUOTE and quote value in check of first character in string. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/list_read.c
Subject: Bug 33253 Author: jvdelisle Date: Wed Oct 3 00:39:58 2007 New Revision: 128975 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=128975 Log: 2007-10-03 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libfortran/33253 * gfortran.dg/namelist_38.f90: New test. * gfortran.dg/namelist_39.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/namelist_38.f90 trunk/gcc/testsuite/gfortran.dg/namelist_39.f90 Modified: trunk/gcc/testsuite/ChangeLog
Subject: Bug 33253 Author: jvdelisle Date: Thu Oct 4 15:57:28 2007 New Revision: 129016 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129016 Log: 2007-10-04 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libfortran/33253 * io/list_read.c (read_character): Use line_buffer to scan ahead for object name or string when no delimiter is found. Modified: trunk/libgfortran/ChangeLog trunk/libgfortran/io/list_read.c
Subject: Bug 33253 Author: jvdelisle Date: Thu Oct 4 16:02:42 2007 New Revision: 129018 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129018 Log: 2007-10-04 Jerry DeLisle <jvdelisle@gcc.gnu.org> PR libfortran/33253 * gfortran.dg/namelist_39.f90: Revise to use long names. Modified: trunk/gcc/testsuite/ChangeLog trunk/gcc/testsuite/gfortran.dg/namelist_39.f90
Subject: Bug number PR33253 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-10/msg00011.html