Bug 34530 - [4.3 regression] namelist read broken when whitespace after &namelist
Summary: [4.3 regression] namelist read broken when whitespace after &namelist
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: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks: 32834
  Show dependency treegraph
 
Reported: 2007-12-19 13:58 UTC by Harald Anlauf
Modified: 2007-12-20 18:07 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2007-12-19 17:39:55


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Harald Anlauf 2007-12-19 13:58:12 UTC
Hi,

namelist read was broken between

GNU Fortran (GCC) 4.3.0 20071216 (experimental) [trunk revision 130986]
(works)

GNU Fortran (GCC) 4.3.0 20071217 (experimental) [trunk revision 131004]
(fails).

This is likely due to the patch for PR34427.

Example: the code below now gives

At line 17 of file gfcbug77.f90 (unit = 10, file = 'gfcbug77.nml')
Fortran runtime error: Cannot match namelist object name !

Backtrace for this error:
  + function translate_error (0x804A2A1)
    at line 311 of file error.c
  + function finalize_transfer (0x804DF79)
    at line 2626 of file transfer.c
  + function gfcbug77 (0x804983C)
    at line 17 of file gfcbug77.f90
  + /lib/libc.so.6(__libc_start_main+0xe0) [0x40071fe0]

% cat gfcbug77.f90
program gfcbug77
  implicit none

  character(len=128) :: file = ""
  logical            :: default
  namelist /BLACKLIST/ file, default

  integer, parameter :: nnml = 10

  open (nnml, file='gfcbug77.nml')
  write(nnml,*) "&blacklist "           ! The trailing space breaks gfortran
  write(nnml,*) "  ! This is a comment within the namelist"
  write(nnml,*) "  file    = 'myfile'"
  write(nnml,*) "  default = F"
  write(nnml,*) "/"
  rewind(nnml)
  read (nnml, nml=BLACKLIST)
  close(nnml)
  write (*,nml=BLACKLIST)
end program gfcbug77

Removing the marked whitespace or removing the comment line
within the namelist lets the program run.

Cheers,
-ha
Comment 1 Dominique d'Humieres 2007-12-19 19:19:27 UTC
The bug is present in gcc version 4.3.0 20071125 (experimental) (GCC).

Comment 2 Tobias Burnus 2007-12-19 22:33:15 UTC
Patch: http://gcc.gnu.org/ml/fortran/2007-12/msg00245.html
Comment 3 Tobias Burnus 2007-12-20 08:17:14 UTC
Subject: Bug 34530

Author: burnus
Date: Thu Dec 20 08:16:48 2007
New Revision: 131099

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131099
Log:
2007-12-20  Tobias Burnus  <burnus@net-b.de>

        PR fortran/34530
        * io/list_read.c (eat_line): Move up in the file.
        (eat_separator): In namelist mode, skip over comment lines.

2007-12-20  Tobias Burnus  <burnus@net-b.de>

        PR fortran/34530
        * gfortran.dg/namelist_44.f90: New.


Added:
    trunk/gcc/testsuite/gfortran.dg/namelist_44.f90
Modified:
    trunk/gcc/testsuite/ChangeLog
    trunk/libgfortran/ChangeLog
    trunk/libgfortran/io/list_read.c

Comment 4 Tobias Burnus 2007-12-20 08:22:21 UTC
FIXED on the trunk (4.3.0).

Thanks for the report.