Bug 20467 - Bad fortran code causes ICE
Summary: Bad fortran code causes ICE
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: 4.0.0
Assignee: Tobias Schlüter
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2005-03-14 04:31 UTC by Anton Blanchard
Modified: 2005-03-14 20:16 UTC (History)
1 user (show)

See Also:
Host:
Target: powerpc64-unknown-linux-gnu
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-03-14 19:08:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Blanchard 2005-03-14 04:31:26 UTC
Im no fortran coder but Im pretty sure this isnt valid:

SUBROUTINE a(b)
        b(c) = 0
END SUBROUTINE a

Using todays cvs:

GNU Fortran 95 (GCC 4.0.0 20050313 (prerelease))

We ICE:

/usr/local/ppc64-4.0/libexec/gcc/powerpc64-linux/4.0.0/f951 f.f90 -quiet
-dumpbase f.f90 -m64 -auxbase f -version -o /tmp/cccadl1s.s
(gdb) backtrace
#0  resolve_formal_arglist (proc=0x105cfaa0)
    at /scratch/anton/toolchain/new2/gcc-4.0/gcc/fortran/resolve.c:123
#1  0x10054bf0 in traverse_ns (st=0x105ba360, func=0x10041710 <find_arglists>)
    at /scratch/anton/toolchain/new2/gcc-4.0/gcc/fortran/symbol.c:2298
#2  0x10054c18 in traverse_ns (st=0x105ba4f0, func=0x10041710 <find_arglists>)
    at /scratch/anton/toolchain/new2/gcc-4.0/gcc/fortran/symbol.c:2301
#3  0x10046d9c in gfc_resolve (ns=0x105cf750)
    at /scratch/anton/toolchain/new2/gcc-4.0/gcc/fortran/resolve.c:247
#4  0x1003db64 in gfc_parse_file ()
    at /scratch/anton/toolchain/new2/gcc-4.0/gcc/fortran/parse.c:2612
#5  0x100570a8 in gfc_be_parse_file (set_yydebug=Variable "set_yydebug" is not
available.
)
    at /scratch/anton/toolchain/new2/gcc-4.0/gcc/fortran/f95-lang.c:265
#6  0x102d09c4 in toplev_main (argc=Variable "argc" is not available.
)
    at /scratch/anton/toolchain/new2/gcc-4.0/gcc/toplev.c:996
#7  0x1007ae40 in main (argc=Variable "argc" is not available.
)
    at /scratch/anton/toolchain/new2/gcc-4.0/gcc/main.c:35

sym->result is NULL:

(gdb) print sym->result
$3 = (struct gfc_symbol *) 0x0

and line 123 is:

/* Set the type of the RESULT, then copy.  */
if (sym->result->ts.type == BT_UNKNOWN)
Comment 1 Andrew Pinski 2005-03-14 04:38:58 UTC
Confirmed, g77 gives the following error:
t.f: In subroutine `a':
t.f:1: 
   SUBROUTINE a(b)
                1
t.f:2: (continued):
           b(c) = 0
           2
Invalid declaration of or reference to symbol `b' at (2) [initially seen at (1)]
Comment 2 Andrew Pinski 2005-03-14 04:39:12 UTC
Confirmed.
Comment 3 Tobias Schlüter 2005-03-14 19:08:00 UTC
It looks like we try to evaluate b as a statement function, which is of course
not valid.  Investigating ...
Comment 4 GCC Commits 2005-03-14 19:55:13 UTC
Subject: Bug 20467

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	tobi@gcc.gnu.org	2005-03-14 19:55:02

Modified files:
	gcc/fortran    : ChangeLog symbol.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: stfunc_2.f90 

Log message:
	fortran/
	PR fortran/20467
	* symbol.c (check_conflict): A dummy argument can't be a statement
	function.
	
	testsuite/
	PR fortran/20467
	* gfortran.dg/stfunc_2.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&r1=1.352&r2=1.353
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/symbol.c.diff?cvsroot=gcc&r1=1.26&r2=1.27
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5164&r2=1.5165
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/stfunc_2.f90.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 5 GCC Commits 2005-03-14 20:15:43 UTC
Subject: Bug 20467

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	tobi@gcc.gnu.org	2005-03-14 20:15:30

Modified files:
	gcc/fortran    : ChangeLog symbol.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gfortran.dg: stfunc_2.f90 

Log message:
	fortran/
	PR fortran/20467
	* symbol.c (check_conflict): A dummy argument can't be a statement
	function.
	
	testsuite/
	PR fortran/20467
	* gfortran.dg/stfunc_2.f90: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.335.2.12&r2=1.335.2.13
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/fortran/symbol.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.26&r2=1.26.2.1
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.43&r2=1.5084.2.44
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gfortran.dg/stfunc_2.f90.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1

Comment 6 Tobias Schlüter 2005-03-14 20:16:45 UTC
Fixed.