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
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
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
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
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
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
Fixed on trunk. Thanks for the report. Paul