This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[gfortran] patch PR 20950 (was: Re: bug fc112)
- From: FranÃois-Xavier Coudert <Francois-Xavier dot Coudert at lcp dot u-psud dot fr>
- To: Gfortran <fortran at gcc dot gnu dot org>
- Cc: Walt Brainerd <walt at fortran dot com>, gcc-patches at gcc dot gnu dot org
- Date: Mon, 11 Apr 2005 17:50:20 +0200
- Subject: [gfortran] patch PR 20950 (was: Re: bug fc112)
- Organization: Laboratoire de Chimie Physique
- References: <4259DAA4.6000309@fortran.com> <425A5C9C.7050107@lcp.u-psud.fr> <425A5F82.2000504@physik.uni-muenchen.de> <425A618A.5020904@lcp.u-psud.fr>
Right now, gfortran can answer "NO" only if the file is either a
directory, or a block-device. Since that can't be determined when
inquiring by unit, I'd say "UNKNOWN" is the right choice.
Patch will follow soon.
Here it is. This simple patch adds a check for NULLity to avoid a segfault.
Regtested on i386-linux. OK for mainline?
FX
2005-04-11 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/20950
* io/inquire.c (inquire_via_unit): Check for the gfc_unit being
NULL when setting ioparm.sequential.
2005-04-11 Francois-Xavier Coudert <coudert@clipper.ens.fr>
PR libfortran/20950
* gfortran.dg/pr20950.f: New test.
Index: libgfortran/io/inquire.c
===================================================================
RCS file: /cvsroot/gcc/gcc/libgfortran/io/inquire.c,v
retrieving revision 1.10
diff -p -u -r1.10 inquire.c
--- libgfortran/io/inquire.c 31 Mar 2005 15:30:05 -0000 1.10
+++ libgfortran/io/inquire.c 11 Apr 2005 15:41:33 -0000
@@ -87,13 +87,16 @@ inquire_via_unit (gfc_unit * u)
if (ioparm.sequential != NULL)
{
- /* disallow an open direct access file to be accessed
- sequentially */
- if (u->flags.access==ACCESS_DIRECT)
- p = "NO";
- else
- p = (u == NULL) ? inquire_sequential (NULL, 0) :
- inquire_sequential (u->file, u->file_len);
+ if (u == NULL)
+ p = inquire_sequential (NULL, 0);
+ else
+ {
+ /* disallow an open direct access file to be accessed sequentially */
+ if (u->flags.access == ACCESS_DIRECT)
+ p = "NO";
+ else
+ p = inquire_sequential (u->file, u->file_len);
+ }
cf_strcpy (ioparm.sequential, ioparm.sequential_len, p);
}
! PR libfortran/20950
! Original bug-report by Walt Brainerd, The Fortran Company
! { dg-do run }
character*20 c
inquire (33, sequential = c)
if (c .ne. "UNKNOWN") call abort
end