The code below is invalid, but it's not that bad that a segfault is called for :-)
$ cat sel_int_kind.f90 program foo contains subroutine foo(i) integer :: i character(len=selected_int_kind(i)) :: c end subroutine bar end program foo $ gfortran sel_int_kind.f90 In file sel_int_kind.f90:3 subroutine foo(i) 1 Error: PROGRAM attribute conflicts with PROCEDURE attribute at (1) In file sel_int_kind.f90:4 integer :: i 1 Error: Unexpected data declaration statement in CONTAINS section at (1) In file sel_int_kind.f90:5 character(len=selected_int_kind(i)) :: c 1 Error: Unexpected data declaration statement in CONTAINS section at (1) In file sel_int_kind.f90:6 end subroutine bar 1 Error: Expecting END PROGRAM statement at (1) sel_int_kind.f90:0: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <URL:http://gcc.gnu.org/bugs.html> for instructions. $ gfortran -v Reading specs from /home/zfkts/lib/gcc/ia64-unknown-linux-gnu/4.0.0/specs Configured with: ../gcc-4.0-20041205/configure --prefix=/home/zfkts --enable-languages=c,c++,f95 --disable-shared Thread model: posix gcc version 4.0.0 20041205 (experimental) Here's a backtrace: $ gdb ~/libexec/gcc/ia64-unknown-linux-gnu/4.0.0/f951 GNU gdb Red Hat Linux (6.1post-1.20040607.17rh) Copyright 2004 Free Software Foundation, Inc. GDB is free software, covered by the GNU General Public License, and you are welcome to change it and/or distribute copies of it under certain conditions. Type "show copying" to see the conditions. There is absolutely no warranty for GDB. Type "show warranty" for details. This GDB was configured as "ia64-redhat-linux-gnu"...Using host libthread_db library "/lib/tls/libthread_db.so.1". (gdb) r sel_int_kind.f90 Starting program: /home/zfkts/libexec/gcc/ia64-unknown-linux-gnu/4.0.0/f951 sel_int_kind.f90 In file sel_int_kind.f90:3 subroutine foo(i) 1 Error: PROGRAM attribute conflicts with PROCEDURE attribute at (1) In file sel_int_kind.f90:4 integer :: i 1 Error: Unexpected data declaration statement in CONTAINS section at (1) In file sel_int_kind.f90:5 character(len=selected_int_kind(i)) :: c 1 Error: Unexpected data declaration statement in CONTAINS section at (1) In file sel_int_kind.f90:6 end subroutine bar 1 Error: Expecting END PROGRAM statement at (1) Program received signal SIGSEGV, Segmentation fault. gfc_resolve_expr (e=0x60000000000e7200) at ../../gcc-4.0-20041205/gcc/fortran/resolve.c:2084 2084 if (sym->attr.flavor == FL_PROCEDURE && !sym->attr.function) (gdb) bt #0 gfc_resolve_expr (e=0x60000000000e7200) at ../../gcc-4.0-20041205/gcc/fortran/resolve.c:2084 #1 0x4000000000085fb0 in resolve_actual_arglist (arg=0x60000000000e6f10) at ../../gcc-4.0-20041205/gcc/fortran/resolve.c:604 #2 0x4000000000083f60 in gfc_resolve_expr (e=0x60000000000e6de0) at ../../gcc-4.0-20041205/gcc/fortran/resolve.c:942 #3 0x400000000008e090 in gfc_resolve (ns=0x60000000000e67f0) at ../../gcc-4.0-20041205/gcc/fortran/resolve.c:4666 #4 0x400000000008dff0 in gfc_resolve (ns=0x60000000000e5bd0) at ../../gcc-4.0-20041205/gcc/fortran/resolve.c:4658 #5 0x400000000007a520 in gfc_parse_file () at ../../gcc-4.0-20041205/gcc/fortran/parse.c:2612 #6 0x40000000000adcb0 in gfc_be_parse_file (set_yydebug=-19536) at ../../gcc-4.0-20041205/gcc/fortran/f95-lang.c:266 #7 0x400000000063d760 in toplev_main (argc=Variable "argc" is not available. ) at ../../gcc-4.0-20041205/gcc/toplev.c:992 #8 0x4000000000106220 in main (argc=2, argv=0x60000fffffffb838) at ../../gcc-4.0-20041205/gcc/main.c:35 -- Summary: segfault after subroutine name confusion Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: fortran AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: Thomas dot Koenig at online dot de CC: gcc-bugs at gcc dot gnu dot org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=18923