https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78833
Bug ID: 78833 Summary: Misleading IOMSG after failed WRITE(...,POS=) on unconnected formatted stream file Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: libfortran Assignee: unassigned at gcc dot gnu.org Reporter: mecej4 at operamail dot com Target Milestone: --- The program below, when run with Gfortran 6.2, runs correctly the first time, and produces an output file. When the program is run a second time, the output file already exists, so the OPEN(..,STATUS='NEW') fails. Everything fine so far. If, however, the program fails to check if the OPEN succeeded and proceeds to do I/O on the file, the IOMSG issued is misleading, saying "...try OPEN with ACCESS='stream' when that is precisely how the OPEN was attempted (but failed). program TEST implicit none integer :: POS1, IOK character(132) :: msg open(10, file='strm.dat', status='new', form='formatted', & access='stream', iostat=IOK, iomsg=msg) if(iok /= 0)write(*,*) 'IOSTAT after OPEN: ',IOK,' ',trim(msg) write(10,'(A)') 'a' inquire(unit=10, pos=POS1) write(10,*) write(10,'(I10)',pos=POS1, iostat=iok, iomsg=msg) 2 if(iok /= 0)write(6,*) 'IOSTAT after WRITE: ',IOK,' ',trim(msg) close(10) end program TEST --- IOSTAT after OPEN: 17 Cannot open file 'strm.dat': File exists IOSTAT after WRITE: 5002 POS=specifier not allowed, Try OPEN with ACCESS='stream' <<<===