https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100954
--- Comment #2 from Taco Jerkface <tacodog311 at gmail dot com> --- Agreed. A typical user will use unit=42, when manually picking unit numbers. However the bug remains for automatic, newunit unit numbers. To reproduce: 1) Open a "newunit" file. 2) close file 3) write to character string 4) "newunit" file appears open, even though it has been closed. A more concise version of the code would be: program inquire implicit none logical opened character(len=256) filename character(len=4) charstring integer iounit, itmp, ierr filename='testfile' ! new unit grabs -10 open(newunit=iounit,file=trim(filename) ) write(*,*) 'Opened unit',iounit ! now -10 is open inquire(iounit, opened=opened,iostat=ierr) write(*,*) 'Unit',iounit,'open?',opened,ierr ! close it close(iounit) write(*,*) 'Closed unit',iounit ! now -10 is closed inquire(iounit, opened=opened,iostat=ierr) write(*,*) 'Unit',iounit,'open?',opened,ierr itmp=0 write(charstring, '(I4.4)') itmp write(*,*) 'wrote into charstring ', trim(charstring) ! now -10 is reported as open again, but it is not inquire(iounit, opened=opened,iostat=ierr) write(*,*) 'Unit',iounit,'open?',opened,ierr endprogram inquire