Bug 33664 - crash on invalid program
Summary: crash on invalid program
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: ---
Assignee: Paul Thomas
URL:
Keywords: ice-on-invalid-code
Depends on:
Blocks:
 
Reported: 2007-10-05 09:50 UTC by Henrik Holst
Modified: 2007-10-14 19:27 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail: 4.3.0
Last reconfirmed: 2007-10-06 11:14:40


Attachments
invalid program which crashes latest trunk (gcc (GCC) 4.3.0 20070927 (experimental) [trunk revision 128829]) (243 bytes, text/plain)
2007-10-05 09:51 UTC, Henrik Holst
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Henrik Holst 2007-10-05 09:50:05 UTC
gfortran crashes on the compile of the following (invalid) Fortran module.

There are two obvious faults with the program:
1. there is no intent
2. there is no dimension to N
Comment 1 Henrik Holst 2007-10-05 09:51:19 UTC
Created attachment 14301 [details]
invalid program which crashes latest trunk (gcc (GCC) 4.3.0 20070927 (experimental) [trunk revision 128829])

test.f:0: internal compiler error: Segmentation fault
Comment 2 Francois-Xavier Coudert 2007-10-05 11:15:04 UTC
Confirmed. Reduced testcase:

$ cat a.f90
module test
contains
  subroutine func_1(u,n)
    integer :: n, u(n(1))
  end subroutine
end module test
$ gfortran a.f90
f951: internal compiler error: Segmentation fault

This is a module writing problem, as confirmed by the backtrace:

#0  0x00000000004448d6 in mio_expr (ep=0x0)
    at ../../../trunk/gcc/fortran/module.c:2794
#1  0x00000000004454bc in mio_array_spec (asp=<value optimized out>)
    at ../../../trunk/gcc/fortran/module.c:1934
#2  0x0000000000445a89 in mio_symbol (sym=0xf592b0)
    at ../../../trunk/gcc/fortran/module.c:3067
#3  0x00000000004461f9 in write_symbol (n=5, sym=0xf592b0)
    at ../../../trunk/gcc/fortran/module.c:3902
#4  0x000000000044638d in write_symbol1 (p=0xf5ae90)
    at ../../../trunk/gcc/fortran/module.c:3969
#5  0x0000000000446355 in write_symbol1 (p=0xf5a110)
    at ../../../trunk/gcc/fortran/module.c:3962
#6  0x0000000000446332 in write_symbol1 (p=0xf5afc0)
    at ../../../trunk/gcc/fortran/module.c:3960
#7  0x0000000000447e71 in gfc_dump_module (name=<value optimized out>,
    dump_flag=1) at ../../../trunk/gcc/fortran/module.c:4106
Comment 3 Paul Thomas 2007-10-06 11:14:40 UTC
This fails in execution, for the same reason:

  call func_1((/1,2/), 1)
contains
  subroutine func_1(u,n)
    integer :: n, u(n(1))
    print *, u
  end subroutine
end

n is determined to be a function and so must be pure, since it is in a specification expression.

Fixing this, causes char_result_7.f90 to fail.  g95 and lahey agree that this is wrong.  I'll submit something soon... ie. just as soon as it has stopped regtesting.

Cheers

Paul
Comment 4 patchapp@dberlin.org 2007-10-07 19:15:18 UTC
Subject: Bug number PR33664

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2007-10/msg00375.html
Comment 5 Paul Thomas 2007-10-12 16:45:59 UTC
Subject: Bug 33664

Author: pault
Date: Fri Oct 12 16:45:46 2007
New Revision: 129267

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=129267
Log:
2007-10-12  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/33664
	* expr.c (gfc_specification_expr): If a function is not
	external, intrinsic or pure is an error.  Set the symbol pure
	to prevent repeat errors.

2007-10-12  Paul Thomas  <pault@gcc.gnu.org>

	PR fortran/33664
	* gfortran.dg/impure_spec_expr_1.f90: New test.
	* gfortran.dg/char_result_7.f90: Remove illegal test.


Added:
    trunk/gcc/testsuite/gfortran.dg/impure_spec_expr_1.f90
Modified:
    trunk/gcc/fortran/ChangeLog
    trunk/gcc/fortran/expr.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gfortran.dg/char_result_7.f90

Comment 6 Paul Thomas 2007-10-14 19:27:54 UTC
Fixed on trunk.

Thanks for the report.

Paul