[Bug fortran/83191] New: Writing a namelist with repeated complex numbers

ccyang at unlv dot edu gcc-bugzilla@gcc.gnu.org
Tue Nov 28 02:39:00 GMT 2017


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83191

            Bug ID: 83191
           Summary: Writing a namelist with repeated complex numbers
           Product: gcc
           Version: 7.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: ccyang at unlv dot edu
  Target Milestone: ---

This is a program that generates the bug on my Mac OS 10.12.6 and 10.13.1 with
the latest MacPorts port gcc7:

program test

implicit none

integer, parameter :: UNIT = 1
character(len=8), parameter :: FILE = "namelist"

complex, dimension(3) :: a = (/ (0.0, 0.0), (0.0, 0.0), (0.0, 0.0) /)

namelist /complex_namelist/ a

open(UNIT, file=FILE)
write(UNIT, nml=complex_namelist)
close(UNIT)

open(UNIT, file=FILE)
read(UNIT, nml=complex_namelist)
close(UNIT)

end program test

It compiles without any warning, but when run, it fails at reading the newly
created namelist:

$ gfortran test.f90 -o test -Wall -Wextra
$ ./test 
At line 17 of file test.f90 (unit = 1, file = 'namelist')
Fortran runtime error: Cannot match namelist object name (0.000000000.00000000)

Error termination. Backtrace:
#0  0x10320d0dc
#1  0x10320d99c
#2  0x10320dfff
#3  0x10329b03a
#4  0x1032a0b78
#5  0x1032a0d9f
#6  0x103203df8
#7  0x103203e6c
$

The problem is in the content of the namelist file:

$ cat namelist
&COMPLEX_NAMELIST
 A= 3*            (0.00000000,0.00000000),
 /
$

where the repeated count (3*) has a gap of blanks to the complex number that
needs to be repeated.

If I have a namelist file without that gap, it can be read in by a program
correctly.

In summary, the reading and writing of a namelist file with a repeated count is
not mutually valid.


More information about the Gcc-bugs mailing list