This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [Patch, FORTRAN] PR61933 Inquire on Internal Unit
- From: Janne Blomqvist <blomqvist dot janne at gmail dot com>
- To: Jerry DeLisle <jvdelisle at charter dot net>
- Cc: gfortran <fortran at gcc dot gnu dot org>, gcc patches <gcc-patches at gcc dot gnu dot org>
- Date: Sun, 7 Sep 2014 07:08:11 +0300
- Subject: Re: [Patch, FORTRAN] PR61933 Inquire on Internal Unit
- Authentication-results: sourceware.org; auth=none
- References: <540B81D8 dot 6050306 at charter dot net>
On Sun, Sep 7, 2014 at 12:51 AM, Jerry DeLisle <jvdelisle@charter.net> wrote:
> Hi,
>
> The attached patch adds a compile time check for negative unit numbers given in
> an INQUIRE statement. A new test case is provided and one updated.
What about units opened with newunit= ? Those have negative unit
numbers. It seems strange that one wouldn't be allowed to inquire such
units? Or if that indeed is the case, I suggest it's a bug in the
standard (one can imagine such happening by forgetting to update
inquire constraints after adding newunit= in f2003).
program negunit
implicit none
logical :: file_exists
integer :: u
open(newunit=u, file="test.dat")
inquire(unit=u, exist=file_exists)
write(*,*) u, file_exists
close(u, status="delete")
end program negunit
Testing with gfortran 4.9.1 (homebrew) on a Mac, the above program prints
-10 F
which is wrong, but a slightly different issue. The almost identical program
program posunit
implicit none
logical :: file_exists
integer :: u=10
open(u, file="test.dat")
inquire(unit=u, exist=file_exists)
write(*,*) u, file_exists
close(u, status="delete")
end program posunit
correctly prints
10 T
--
Janne Blomqvist