Bug 33421 - [4.3 Regression] Weird quotation of namelist output of character arrays
Summary: [4.3 Regression] Weird quotation of namelist output of character arrays
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Jerry DeLisle
URL:
Keywords: wrong-code
: 33422 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-09-13 18:36 UTC by Toon Moene
Modified: 2007-09-28 03:10 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work: 4.2.2
Known to fail: 4.3.0
Last reconfirmed: 2007-09-20 03:33:28


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Toon Moene 2007-09-13 18:36:29 UTC
This program:

      character*20 a(3)
      namelist / nam / a
      read (4, nml=nam)
      write(6, nml=nam)
      end

given the following input (fort.4):

 &nam
 a(1)='aap noot mies wim zus jet',
 a(2)='surf.pressure',
 a(3)='apekool',
 /

produces the following output:

&NAM
 A=aap noot mies wim zu,a(2)='surf.pressure',a(3)='apekool'      ,  /

This mixing of quoted and unquoted strings cannot be correct.  The a(2) and a(3) are weird.
Comment 1 Tobias Burnus 2007-09-13 18:40:02 UTC
Another example. With gfortran 4.3.0 it print the following, with NAG f95, g95, ifort and gfortran 4.2.2 the expected.

b1: " AAP NOOT MIES WIM ZUS JET                   "
b2: "b(2)='SURF.PRESSURE'                         "
b3: "b(3)='APEKOOL'                               "

Expected:
b1: " AAP NOOT MIES WIM ZUS JET                   "
b2: "SURF.PRESSURE                                "
b3: "APEKOOL                                      "


program test
implicit none
character(len=45) :: b(3)
namelist /nam/ b
b = 'x'
open(99)
write(99,'(4(a,/),a)') "&NAM", &
      " b(1)=' AAP NOOT MIES WIM ZUS JET',", &
      " b(2)='SURF.PRESSURE',", &
      " b(3)='APEKOOL',", &
      " /"
rewind(99)
read(99,nml=nam)
close(99,status='delete')

print '(3a)', 'b1: "',b(1),'"'
print '(3a)', 'b2: "',b(2),'"'
print '(3a)', 'b3: "',b(3),'"'

print '(/,"Expected:")'
print '(a)', 'b1: " AAP NOOT MIES WIM ZUS JET                   "'
print '(a)', 'b2: "SURF.PRESSURE                                "'
print '(a)', 'b3: "APEKOOL                                      "'
end program test
Comment 2 Toon Moene 2007-09-13 18:43:34 UTC
*** Bug 33422 has been marked as a duplicate of this bug. ***
Comment 3 Toon Moene 2007-09-13 18:44:33 UTC
Two witnesses should be enough ...
Comment 4 Jerry DeLisle 2007-09-20 03:33:28 UTC
I am investigating.
Comment 5 Jerry DeLisle 2007-09-28 02:57:52 UTC
Subject: Bug 33421

Author: jvdelisle
Date: Fri Sep 28 02:57:41 2007
New Revision: 128857

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

	PR libfortran/33421
	* io/list_read.c (read_character): Revert r128057.

Modified:
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/list_read.c

Comment 6 Jerry DeLisle 2007-09-28 03:10:35 UTC
I have reverted the offending patch and will reopen pr33253, the least of the two evils.  This is one of those bugs where the fix for one breaks the other.  I am still trying to puzzle it out.