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

            Bug ID: 123012
           Summary: Silent acceptance of unquoted character items in
                    namelist input
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libfortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: anlauf at gcc dot gnu.org
  Target Milestone: ---

The following code is silently handled by gfortran (and Intel), but
considered bad by NAG and Nvidia:

program nml_quotes_bug
  implicit none
  integer      :: unit = 10
  character(8) :: c1, c2
  namelist /tovs_obs_chan/ c1, c2
  open (unit ,file="nml-quotes-bug.nml")
  write(unit,*) "&tovs_obs_chan"
  write(unit,*) "  c1 = '1',"
  write(unit,*) "  c2 =  2 ,"
  write(unit,*) "/"
  rewind(unit)
  read (unit ,nml=tovs_obs_chan)
  close(unit ,status="delete")
end program nml_quotes_bug

I get:

! NAG:
! Runtime Error: nml-quotes-bug.f90, line 12: Invalid character '2' in NAMELIST
input
! Program terminated by I/O error on unit 10
(File="nml-quotes-bug.nml",Formatted,Sequential)
! Aborted

! Nvidia:
! FIO-F-231/namelist read/unit=10/error on data conversion.
!  File name = 'nml-quotes-bug.nml',    formatted, sequential access   record =
3
!  In source file nml-quotes-bug.f90, at line number 12

This looks consistent with F2023:

13.11.3.3 Namelist input values

7th paragraph:

"When the next effective item is of type character, the input form
consists of a sequence of zero or more rep‐chars whose kind type
parameter is implied by the kind of that effective item, delimited
by apostrophes or quotes. ..."

We should reject or at least warn with a -std= option.

Reply via email to