http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56675



             Bug #: 56675

           Summary: I/O: Check edit descriptors with READ/WRITE used in

                    FORMAT statements

    Classification: Unclassified

           Product: gcc

           Version: 4.9.0

            Status: UNCONFIRMED

          Keywords: diagnostic

          Severity: normal

          Priority: P3

         Component: fortran

        AssignedTo: unassig...@gcc.gnu.org

        ReportedBy: bur...@gcc.gnu.org





https://groups.google.com/forum/#!topic/comp.lang.fortran/BxWaYSkmV2w



The following code shows that the special checks for READ/WRITE/PRINT do not

get checked for with FORMAT but only with a string.



Seemingly, the format is checked when FORMAT is encountered - one should

consider to do additionally a check if READ/WRITE/PRINT is used.



[The latter becomes even more useful when looking at the types of the arguments

(e.g. "a" edit descriptor with a "real" expression/variable). However,

currently this is only checked at run time. For compile time, it should be

doable if the I/O list doesn't contain nonconst-shape arrays and no

io-do-lists.]









  implicit none

  integer :: z



! OK: Diagnosed.  (Side note: Also diagnosed by NAG.)

!  character(len=*), parameter :: str = '(i0)'

!  read  (*,str) z ! Positive width required in format string

!  read  (*,"(i0)") z ! "Positive width required in format string"



! Not diagnosed but diagnosable. (Also not diagnosed by NAG.)

  read  (*, 99) z ! 'Wrongly' accepted (at compile time)

  99 FORMAT (i0)  ! (gives error at run time)



! RFC: Validly rejected or not? (Note: Also rejected by NAG)

!   read (*, 100) z   ! Rejected at run time (but not used;

!   100 FORMAT (i2,i0)! may it reject it or not?)

end

Reply via email to