$ uname -a Linux glasgow.nag.co.uk 2.6.27.24-170.2.68.fc10.x86_64 #1 SMP Wed May 20 22:47:23 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux $ gfortran --version GNU Fortran (GCC) 4.5.0 20090716 (experimental) $ cat search.f90 SUBROUTINE SEARCH(ITEMVAL) CHARACTER (*) :: ITEMVAL CHARACTER (LEN(ITEMVAL)) :: ITEM INTRINSIC LEN END $ gfortran -c search.f90 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. The file compiles happily if the INTRINSIC LEN line is removed.
A 4.5 Regression with the following bt Program received signal SIGSEGV, Segmentation fault. 0x000000000050f5a4 in resolve_symbol (sym=0x12dd060) at /data03/vondele/gcc_trunk/gcc/gcc/fortran/resolve.c:7873 7873 e = sym->ts.cl->length; (gdb) bt #0 0x000000000050f5a4 in resolve_symbol (sym=0x12dd060) at /data03/vondele/gcc_trunk/gcc/gcc/fortran/resolve.c:7873 #1 0x000000000051f677 in traverse_ns (st=0x1276850, func=0x50e1b0 <resolve_symbol>) at /data03/vondele/gcc_trunk/gcc/gcc/fortran/symbol.c:3195 #2 0x000000000050b920 in resolve_types (ns=0x12dc680) at /data03/vondele/gcc_trunk/gcc/gcc/fortran/resolve.c:10901 #3 0x0000000000507347 in gfc_resolve (ns=0x12dc680) at /data03/vondele/gcc_trunk/gcc/gcc/fortran/resolve.c:10990 #4 0x000000000050ef06 in resolve_symbol (sym=0x12dbf50) at /data03/vondele/gcc_trunk/gcc/gcc/fortran/resolve.c:9847 #5 0x000000000051f677 in traverse_ns (st=0x1282720, func=0x50e1b0 <resolve_symbol>) at /data03/vondele/gcc_trunk/gcc/gcc/fortran/symbol.c:3195 #6 0x000000000050b920 in resolve_types (ns=0x12d8a10) at /data03/vondele/gcc_trunk/gcc/gcc/fortran/resolve.c:10901 #7 0x0000000000507347 in gfc_resolve (ns=0x12d8a10) at /data03/vondele/gcc_trunk/gcc/gcc/fortran/resolve.c:10990 #8 0x00000000004fb9ca in gfc_parse_file () at /data03/vondele/gcc_trunk/gcc/gcc/fortran/parse.c:3924 #9 0x000000000052f62d in gfc_be_parse_file (set_yydebug=<value optimized out>) at /data03/vondele/gcc_trunk/gcc/gcc/fortran/f95-lang.c:241 #10 0x00000000007fa0a3 in toplev_main (argc=13, argv=0x7ffff92ed248) at /data03/vondele/gcc_trunk/gcc/gcc/toplev.c:1026 #11 0x00007fd3eff50436 in __libc_start_main () from /lib64/libc.so.6 #12 0x000000000049b2f9 in _start ()
Crash happens at: resolve_fl_variable (gfc_symbol *sym, int mp_flag) [...] if (sym->ts.type == BT_CHARACTER) { /* Make sure that character string variables with assumed length are dummy arguments. */ e = sym->ts.cl->length; Seemingly regressed between 2009-04-15-r14607 (working) and 2009-04-27-r146825 (failing). Likely due to: r146554 | janus | 2009-04-22 11:05:58 +0200 (Wed, 22 Apr 2009) | 38 lines PR fortran/39735
This was indeed caused by my r146554. Here's a patch: Index: gcc/fortran/symbol.c =================================================================== --- gcc/fortran/symbol.c (revision 149848) +++ gcc/fortran/symbol.c (working copy) @@ -3927,6 +3927,9 @@ gfc_copy_formal_args_intr (gfc_symbol *d formal_arg->sym->attr.flavor = FL_VARIABLE; formal_arg->sym->attr.dummy = 1; + if (formal_arg->sym->ts.type == BT_CHARACTER) + formal_arg->sym->ts.cl = gfc_get_charlen (); + /* If this isn't the first arg, set up the next ptr. For the last arg built, the formal_arg->next will never get set to anything other than NULL. */
The patch in comment #3 even survives a regtest on x86_64-unknown-linux-gnu. Ok to commit with the reporter's test case?
Subject: Bug 40822 Author: janus Date: Fri Jul 24 11:00:01 2009 New Revision: 150047 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150047 Log: 2009-07-24 Janus Weil <janus@gcc.gnu.org> PR fortran/40822 * array.c (gfc_resolve_character_array_constructor): Use new function gfc_new_charlen. * decl.c (add_init_expr_to_sym,variable_decl,match_char_spec, gfc_match_implicit): Ditto. * expr.c (gfc_simplify_expr): Ditto. * gfortran.h (gfc_new_charlen): New prototype. * iresolve.c (check_charlen_present,gfc_resolve_char_achar): Use new function gfc_new_charlen. * module.c (mio_charlen): Ditto. * resolve.c (gfc_resolve_substring_charlen, gfc_resolve_character_operator,fixup_charlen,resolve_fl_derived, resolve_symbol): Ditto. * symbol.c (gfc_new_charlen): New function to create a new gfc_charlen structure and add it to a namespace. (gfc_copy_formal_args_intr): Make sure ts.cl is present for CHARACTER variables. 2009-07-24 Janus Weil <janus@gcc.gnu.org> PR fortran/40822 * gfortran.dg/char_length_16.f90: New. Added: trunk/gcc/testsuite/gfortran.dg/char_length_16.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/array.c trunk/gcc/fortran/decl.c trunk/gcc/fortran/expr.c trunk/gcc/fortran/gfortran.h trunk/gcc/fortran/iresolve.c trunk/gcc/fortran/module.c trunk/gcc/fortran/resolve.c trunk/gcc/fortran/symbol.c trunk/gcc/testsuite/ChangeLog
Fixed with r150047. Closing.
Subject: Bug 40822 Author: hjl Date: Tue Jul 28 16:51:19 2009 New Revision: 150169 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=150169 Log: 2009-07-28 H.J. Lu <hongjiu.lu@intel.com> Backport from mainline: 2009-07-27 Janus Weil <janus@gcc.gnu.org> PR fortran/40848 * gfortran.dg/altreturn_7.f90: New. 2009-07-27 Simon Baldwin <simonb@google.com> PR testsuite/40829 * gcc.dg/vect/no-scevccp-noreassoc-outer-2.c: Extended array 'a' so that indexing no longer runs off array end. 2009-07-24 Janus Weil <janus@gcc.gnu.org> PR fortran/40822 * gfortran.dg/char_length_16.f90: New. Added: branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/altreturn_7.f90 - copied unchanged from r150168, trunk/gcc/testsuite/gfortran.dg/altreturn_7.f90 branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/char_length_16.f90 - copied unchanged from r150168, trunk/gcc/testsuite/gfortran.dg/char_length_16.f90 Modified: branches/gcc-4_4-branch/gcc/testsuite/ChangeLog branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vect/no-scevccp-noreassoc-outer-2.c