http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50404

kargl at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kargl at gcc dot gnu.org

--- Comment #1 from kargl at gcc dot gnu.org 2011-09-15 15:47:33 UTC ---
Program received signal SIGSEGV, Segmentation fault.
0x00000000004d17e9 in gfc_resolve_close (close=0x202007220)
    at ../../gcc4x/gcc/fortran/io.c:2298
2298      if (close->unit->expr_type == EXPR_CONSTANT
(gdb) bt
#0  0x00000000004d17e9 in gfc_resolve_close (close=0x202007220)
    at ../../gcc4x/gcc/fortran/io.c:2298
#1  0x0000000000501bbf in resolve_code (code=0x2020a6300, ns=0x2021bb200)
    at ../../gcc4x/gcc/fortran/resolve.c:9382
#2  0x00000000005028f9 in resolve_codes (ns=0x2021bb200)
    at ../../gcc4x/gcc/fortran/resolve.c:13665
#3  0x0000000000502a24 in gfc_resolve (ns=0x2021bb200)
    at ../../gcc4x/gcc/fortran/resolve.c:13692
#4  0x00000000004f5d04 in resolve_all_program_units ()
    at ../../gcc4x/gcc/fortran/parse.c:4336
#5  gfc_parse_file () at ../../gcc4x/gcc/fortran/parse.c:4602
#6  0x000000000052cdce in gfc_be_parse_file ()
    at ../../gcc4x/gcc/fortran/f95-lang.c:250
#7  0x00000000008c806b in compile_file () at ../../gcc4x/gcc/toplev.c:548
#8  do_compile () at ../../gcc4x/gcc/toplev.c:1886
#9  0x00000000008c8c95 in toplev_main (argc=2, argv=0x7fffffffd508)
    at ../../gcc4x/gcc/toplev.c:1962
#10 0x00000000004900dc in _start ()

(gdb) print close
$1 = (gfc_close *) 0x202007220
(gdb) print *close
$2 = {unit = 0x0, status = 0x0, iostat = 0x2020a6180, iomsg = 0x0, err = 0x0}

>From f2003

C907 (R909) A file-unit-number shall be specified; if the optional
  characters UNIT= are omitted, the file-unit-number shall be the
  first item in the close-spec-list.

troutmask:sgk[256] gfc4x -c a.f
a.f:5.72:

      close(iostat=i)                                                   
                                                                        1
Error: CLOSE statement at (1) requires a UNIT number


Index: io.c
===================================================================
--- io.c        (revision 178782)
+++ io.c        (working copy)
@@ -2295,6 +2295,12 @@ gfc_resolve_close (gfc_close *close)
   if (gfc_reference_st_label (close->err, ST_LABEL_TARGET) == FAILURE)
     return FAILURE;

+  if (close->unit == NULL)
+    {
+      gfc_error ("CLOSE statement at %C requires a UNIT number");
+      return FAILURE;
+    }
+
   if (close->unit->expr_type == EXPR_CONSTANT
       && close->unit->ts.type == BT_INTEGER
       && mpz_sgn (close->unit->value.integer) < 0)

Reply via email to