Bug 36657 - Namelist reading bug with string constant immediately followed by comment
Summary: Namelist reading bug with string constant immediately followed by comment
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: libfortran (show other bugs)
Version: 4.3.1
: P3 normal
Target Milestone: 4.3.2
Assignee: Jerry DeLisle
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-06-27 20:13 UTC by Harald Anlauf
Modified: 2008-07-16 14:35 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2008-06-28 01:34:59


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Anlauf 2008-06-27 20:13:04 UTC
Hi,

the following program shows a runtime bug with gfortran 4.3.x:

% cat gfcbug79.f90 
program gfcbug79
  implicit none

  integer, parameter :: nnml = 10

  character(len=8)  :: model = ""
  namelist /NML/       model

  open (nnml, file='gfcbug79.nml')
  write(nnml,*) "&nml"
  write(nnml,*) "  model='foo'! This is a just comment"
  write(nnml,*) "/"
  rewind(nnml)
  read (nnml, nml=NML)
  close(nnml)
  write (*,nml=NML)
end program gfcbug79
% gfc gfcbug79.f90 && ./a.out 
At line 14 of file gfcbug79.f90 (unit = 10, file = 'gfcbug79.nml')
Fortran runtime error: Invalid string input in item 0
%

Inserting a blank before the comment character ("!")
is a workaround, but gfortran should nevertheless be fixed.

Cheers,
-ha
Comment 1 Jerry DeLisle 2008-06-28 01:34:59 UTC
I will investigate this.  i have another namelist patch I am working as well.
Comment 2 Jerry DeLisle 2008-06-28 21:47:39 UTC
Subject: Bug 36657

Author: jvdelisle
Date: Sat Jun 28 21:46:53 2008
New Revision: 137236

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137236
Log:
2008-06-28  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/36657
	* io/list_read.c (read_character): Check for '!' along with separators.
	(find_nml_name): Likewise and eat the comment if found.

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

Comment 3 Jerry DeLisle 2008-06-28 21:56:29 UTC
I plan to backport this one to 4.3.
Comment 4 Jerry DeLisle 2008-07-02 04:45:07 UTC
Subject: Bug 36657

Author: jvdelisle
Date: Wed Jul  2 04:44:21 2008
New Revision: 137336

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137336
Log:
2008-07-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR fortran/36676
	PR fortran/36657
	PR fortran/36546
	Backport from trunk.
	* io/list_read.c (find_nml_name): Use unget_char before eat_separator.
	(read_character): Check for '!' along with separators.
	(eat_separator): Add tab character to condition	for looping past
	whitespace.

Modified:
    branches/gcc-4_3-branch/libgfortran/ChangeLog
    branches/gcc-4_3-branch/libgfortran/io/list_read.c

Comment 5 Jerry DeLisle 2008-07-02 04:53:39 UTC
Subject: Bug 36657

Author: jvdelisle
Date: Wed Jul  2 04:52:47 2008
New Revision: 137337

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=137337
Log:
2008-07-01  Jerry DeLisle  <jvdelisle@gcc.gnu.org

	PR fortran/36676
	PR fortran/36657
	PR fortran/36546
	PR fortran/36538
	* gfortran.dg/namelist_50.f90
	* gfortran.dg/namelist_51.f90
	* gfortran.dg/namelist_48.f90
	* gfortran.dg/namelist_49.f90

Added:
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/namelist_48.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/namelist_49.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/namelist_50.f90
    branches/gcc-4_3-branch/gcc/testsuite/gfortran.dg/namelist_51.f90
Modified:
    branches/gcc-4_3-branch/gcc/testsuite/ChangeLog

Comment 6 Jerry DeLisle 2008-07-02 05:18:50 UTC
Fixed on Trunk and 4.3
Comment 7 littlestar 2008-07-16 14:24:56 UTC
Target Milestone is 4.3.3?
Comment 8 Bernhard Reutner-Fischer 2008-07-16 14:35:15 UTC
The target milestone does not matter in this case.
The fix will be in the next 4.3.x release which will be 4.3.2, from the looks.