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

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #4 from kargl at gcc dot gnu.org ---
(In reply to mecej4 from comment #3)
> I understand what happens, and this is not a bug per se', but in normal
> usage the message wording can be confusing.
> 
> During the second run, the OPEN fails because 'NEW' is specified and the
> file already exists.
> 
> If the program does not stop when the OPEN failed and goes on to the WRITE,
> the unit is not open or connected, so an implicit OPEN is performed to file
> 'FORT10', with no keyword options in the implicit OPEN. Therefore, the newly
> created FORT10 is not a stream file. but a simple formatted sequential file,
> and the WRITE fails because it contains a POS= clause. 
> 
> These details are not immediately evident when one looks at the WRITE
> statement, hence the possibility of confusion. Wording such as "'POS='
> clause in WRITE to sequential formatted file FORT10" would alert the user to
> what went wrong and how to resolve the problem.

Looks like a programming error on the part of a user.  If a
programmer requests the iostat of an OPEN, and then refuses
to act of the return value then the programmer gets want
the get.  Specifically your bug is here:

    if(iok /= 0)write(*,*) 'IOSTAT after OPEN: ',IOK,' ',trim(msg)

A properly written program would do

    if(iok /= 0)then
      write(*,*) 'IOSTAT after OPEN: ',IOK,' ',trim(msg)
      stop
    end if

or 

    if(iok /= 0)then
      write(*,*) 'IOSTAT after OPEN: ',IOK,' ',trim(msg)
      call do_something_clever_here.
    end if

Reply via email to