This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

[gfortran] patch PR 20950 (was: Re: bug fc112)


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

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