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
The bug is present in gcc version 4.3.0 20071125 (experimental) (GCC).
Patch: http://gcc.gnu.org/ml/fortran/2007-12/msg00245.html
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
FIXED on the trunk (4.3.0). Thanks for the report.