Bug 43592

Summary: Unexpected INTERFACE statement in INTERFACE block at (1)
Product: gcc Reporter: Joost VandeVondele <Joost.VandeVondele>
Component: fortranAssignee: kargls
Status: RESOLVED FIXED    
Severity: normal CC: dfranke, gcc-bugs
Priority: P3 Keywords: error-recovery, ice-on-invalid-code
Version: 4.5.0   
Target Milestone: 4.5.1   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2010-04-30 18:09:12

Description Joost VandeVondele 2010-03-30 19:01:00 UTC
> cat small.f90
  interface assignment (=)
  interface pseudo_scalar
  pure function double_tensor2odd (x, t2) result (xt2)

> gfortran small.f90
small.f90:2.25:

  interface pseudo_scalar
                         1
Error: Unexpected INTERFACE statement in INTERFACE block at (1)
f951: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.
Comment 1 Dominique d'Humieres 2010-03-30 20:00:39 UTC
Confirmed:

Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000000
0x00000001000674c8 in parse_spec (st=ST_INTERFACE) at ../../p_work/gcc/fortran/parse.c:2239
2239		    gfc_add_function (&sym->attr, sym->name, NULL);
(gdb) bt
#0  0x00000001000674c8 in parse_spec (st=ST_INTERFACE) at ../../p_work/gcc/fortran/parse.c:2239
#1  0x000000010006838d in parse_progunit (st=ST_ARITHMETIC_IF) at ../../p_work/gcc/fortran/parse.c:3758
#2  0x000000010006942c in gfc_parse_file () at ../../p_work/gcc/fortran/parse.c:4192
#3  0x00000001000a291c in gfc_be_parse_file (set_yydebug=<value temporarily unavailable, due to optimizations>) at ../../p_work/gcc/fortran/f95-lang.c:239
#4  0x00000001006d6b5a in toplev_main (argc=2, argv=0x7fff5fbfd9f0) at ../../p_work/gcc/toplev.c:1053
#5  0x00000001000019e4 in start ()

Not a regression, I get the "Bus error" for 4.2.4, 4.3.4, 4.4.2, and trunk.
Comment 2 kargls 2010-04-30 18:09:12 UTC
I have a patch.
Comment 4 kargls 2010-05-03 17:57:29 UTC
Subject: Bug 43592

Author: kargl
Date: Mon May  3 17:57:14 2010
New Revision: 158998

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=158998
Log:
2010-05-03  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/43592
	* fortran/parse.c (parse_interface): Do not dereference a NULL pointer.

2010-05-03  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/43592
	* gfortran.dg/unexpected_interface.f90: New test.

Added:
    trunk/gcc/testsuite/gfortran.dg/unexpected_interface.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/parse.c
    trunk/gcc/testsuite/ChangeLog

Comment 5 kargls 2010-05-05 15:31:46 UTC
Subject: Bug 43592

Author: kargl
Date: Wed May  5 15:30:54 2010
New Revision: 159068

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=159068
Log:
2010-05-05  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/43592
	* fortran/parse.c (parse_interface): Do not dereference a NULL pointer.

2010-05-05  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/43592
	* gfortran.dg/unexpected_interface.f90: New test.

Added:
    branches/gcc-4_5-branch/gcc/testsuite/gfortran.dg/unexpected_interface.f90
Modified:
    branches/gcc-4_5-branch/gcc/fortran/ChangeLog
    branches/gcc-4_5-branch/gcc/fortran/parse.c
    branches/gcc-4_5-branch/gcc/testsuite/ChangeLog

Comment 6 kargls 2010-05-05 15:33:17 UTC
Fixed on trunk and 4.5. Closing.