[Bug fortran/89783] New: Can do an internal READ of a character array when it is a parameter, but not a scalar character parameter

urbanjost at comcast dot net gcc-bugzilla@gcc.gnu.org
Thu Mar 21 02:44:00 GMT 2019


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

            Bug ID: 89783
           Summary: Can do an internal READ of a character array when it
                    is a parameter, but not a scalar character parameter
           Product: gcc
           Version: 7.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: fortran
          Assignee: unassigned at gcc dot gnu.org
          Reporter: urbanjost at comcast dot net
  Target Milestone: ---

Inconsistently, a scalar parameter CHARACTER variable fails with an internal
READ,
but a vector parameter CHARACTER variable works with an internal READ.
Not actually sure which one is wrong, but it is inconsistent. Could not find 
anything in the Fortran standard that definitively cleared it up, other than
saying that 

      · "A record of an internal file is a scalar character variable".

with emphasis on "variable"(?). It seems one of them should be wrong, though.

This fails:

   program nanio
   character(len=*),parameter :: VALUE='NaN'
      read(VALUE,*)float
      write(*,*)float
   end program nanio

 PRODUCES THIS ERROR...

    read(VALUE,*)float
        1
    Error: UNIT specification at (1) must be an INTEGER expression or a
CHARACTER variable

This works:

   program nanio
   character(len=*),parameter :: VALUES(*)=[character(len=10) ::
'NaN','NAN','nan','Inf','INF','inf','Infinity']
   do i=1,size(VALUES)
      read(VALUES(i),*)float
      write(*,*)float
   enddo
   end program nanio


More information about the Gcc-bugs mailing list