This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libfortran/84529] New: INQUIRE fails on "recycled" internal units
- From: "albandil at atlas dot cz" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 23 Feb 2018 14:29:06 +0000
- Subject: [Bug libfortran/84529] New: INQUIRE fails on "recycled" internal units
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84529
Bug ID: 84529
Summary: INQUIRE fails on "recycled" internal units
Product: gcc
Version: 7.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libfortran
Assignee: unassigned at gcc dot gnu.org
Reporter: albandil at atlas dot cz
Target Milestone: ---
The following program fails with the error "Inquire statement identifies an
internal file" at the call to INQUIRE.
program TestRecycleInternalUnit
implicit none
integer :: iunit, ipos
character(len=10) :: sstream
write(sstream,'(I0)') 12345
print *, 'sstream = ', sstream
open(newunit=iunit, file='output.bin', access="stream", form="unformatted")
inquire(iunit,pos=ipos)
print *, 'n = ', ipos
close(iunit)
end program TestRecycleInternalUnit
I looked into the code of libgfortran/io/open.c (and around) and it seems that
OPEN reuses the cached internal unit (-10 in this case) used for writing to
string. However, the member "internal_unit_kind" of the unit structure is not
reset to 0 in the "st_open" function. This makes the subsequent INQUIRE think
that its argument is an internal unit.