This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gfortran] patch PR 20660


François-Xavier Coudert wrote:

The attached trivial patch fixes PR libfortran/20660 (INQUIRE by unit number reported wrong EXIST value).

Fortran details: if I understand correctly, INQUIREing the EXISTence of a given unit number should always be TRUE since gfortran can open any arbitrary unit number.

A unit number must be nonnegative, so it would be better to return false for a negative number. But this is much better than it was, as people (eg me) use it to find an available unit # to use in an open statement by finding a unit that exists and is not connected (rational people would probably start the hunt at 11, or some such number, so it will work for most as is).

In trying this, I found a couple of other oddities that I will send.
They would be pretty far down the list of things to fix, I would think.

*strapped and regtested on (i686-linux) for both 4.0 and mainline . OK?



2005-03-29 Francois-Xavier Coudert <coudert@clipper.ens.fr>

    PR libfortran/20660
    * io/inquire.c (inquire_via_unit): EXIST should always be TRUE.


2005-03-29 Francois-Xavier Coudert <coudert@clipper.ens.fr>


    PR libfortran/20660
    * gfortran.dg/pr20660.f: New test.

------------------------------------------------------------------------

Index: libgfortran/io/inquire.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/inquire.c,v
retrieving revision 1.9
diff -p -u -r1.9 inquire.c
--- libgfortran/io/inquire.c	30 Jan 2005 13:16:19 -0000	1.9
+++ libgfortran/io/inquire.c	29 Mar 2005 10:33:52 -0000
@@ -46,7 +46,7 @@ inquire_via_unit (gfc_unit * u)
  const char *p;

  if (ioparm.exist != NULL)
-    *ioparm.exist = (u != NULL);
+    *ioparm.exist = 1;

if (ioparm.opened != NULL)
*ioparm.opened = (u != NULL);


------------------------------------------------------------------------

! PR libfortran/20660
! {dg-do run}
integer k
logical ck
do k = 1, 20
inquire(unit=k, exist=ck)
if (.not. ck) call abort
end do
end




--
Walt Brainerd         +1-877-355-6640 (voice & fax)
The Fortran Company   +1-520-760-1397 (outside USA)
6025 N. Wilmot Road   walt@fortran.com
Tucson, AZ 85750 USA  http://www.fortran.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]