It seems something broke C_ASSOCIATED: PROGRAM c_assoc use iso_c_binding type(c_ptr) :: x PRINT *, C_ASSOCIATED(x) END PROGRAM c_assoc breaks here for me: Starting program: /localdata/libexec/gcc/i686-pc-linux-gnu/4.4.3/f951 foo.f90 -quiet -dumpbase foo.f90 -mtune=generic -march=athlon64 -auxbase foo -version -fintrinsic-modules-path /localdata/lib/gcc/i686-pc-linux-gnu/4.4.3/finclude -o /tmp/ccEGPG6g.s GNU Fortran (GCC) Version 4.4.3 (i686-pc-linux-gnu) kompiliert von GNU-C-Version 4.4.3, GMP-Version 4.3.1, MPFR-Version 2.4.2. GGC-Heuristik: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Program received signal SIGSEGV, Segmentation fault. 0x08135756 in gfc_conv_expr_reference (se=0xbfffed78, expr=0x8906ce8) at ../../gcc-4.4.3/gcc/fortran/trans-expr.c:3960 3960 && expr->value.function.esym->result->attr.pointer (gdb) bt #0 0x08135756 in gfc_conv_expr_reference (se=0xbfffed78, expr=0x8906ce8) at ../../gcc-4.4.3/gcc/fortran/trans-expr.c:3960 #1 0x08144681 in gfc_trans_transfer (code=0x8906d58) at ../../gcc-4.4.3/gcc/fortran/trans-io.c:2223 #2 0x0810db28 in gfc_trans_code (code=0x8906d58) at ../../gcc-4.4.3/gcc/fortran/trans.c:1207 #3 0x0814956f in build_dt (function=<value optimized out>, code=<value optimized out>) at ../../gcc-4.4.3/gcc/fortran/trans-io.c:1803 #4 0x0810db58 in gfc_trans_code (code=0x8906e30) at ../../gcc-4.4.3/gcc/fortran/trans.c:1179 #5 0x0812d27d in gfc_generate_function_code (ns=0x88ff070) at ../../gcc-4.4.3/gcc/fortran/trans-decl.c:3886 #6 0x080c5215 in gfc_parse_file () at ../../gcc-4.4.3/gcc/fortran/parse.c:3851 #7 0x0810a18d in gfc_be_parse_file (set_yydebug=0) at ../../gcc-4.4.3/gcc/fortran/f95-lang.c:236 #8 0x0833b18a in compile_file (argc=14, argv=0xbffff304) at ../../gcc-4.4.3/gcc/toplev.c:970 #9 do_compile (argc=14, argv=0xbffff304) at ../../gcc-4.4.3/gcc/toplev.c:2197 #10 toplev_main (argc=14, argv=0xbffff304) at ../../gcc-4.4.3/gcc/toplev.c:2229 #11 0x0815c2bb in main (argc=14, argv=0xbffff304) at ../../gcc-4.4.3/gcc/main.c:35
This looks like a 4.4.2 -> 4.4.3 regression. It worls with 4.3.{2,3,4} and 4.4.2
Confirmed. Caused by the fix for PR 41777.
Patch: diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index 5370f0d..8aa57b6 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -4542,6 +4542,8 @@ get_iso_c_sym (gfc_symbol *old_sym, char *new_name, new_symtree->n.sym->module = gfc_get_string (old_sym->module); new_symtree->n.sym->from_intmod = old_sym->from_intmod; new_symtree->n.sym->intmod_sym_id = old_sym->intmod_sym_id; + if (old_sym->attr.function) + new_symtree->n.sym->result = new_symtree->n.sym; /* Build the formal arg list. */ build_formal_args (new_symtree->n.sym, old_sym, add_optional_arg);
Subject: Bug 43303 Author: burnus Date: Wed Mar 10 18:56:46 2010 New Revision: 157364 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157364 Log: 2010-03-10 Tobias Burnus <burnus@net-b.de PR fortran/43303 * symbol.c (get_iso_c_sym): Set sym->result. 2010-03-10 Tobias Burnus <burnus@net-b.de PR fortran/43303 * gfortran.dg/c_assoc_3.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/c_assoc_3.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/symbol.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 43303 Author: burnus Date: Thu Mar 11 11:10:37 2010 New Revision: 157383 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157383 Log: 2010-03-11 Tobias Burnus <burnus@net-b.de PR fortran/43303 * symbol.c (get_iso_c_sym): Set sym->result. 2010-03-11 Tobias Burnus <burnus@net-b.de PR fortran/43303 * gfortran.dg/c_assoc_3.f90: New test. Added: branches/gcc-4_4-branch/gcc/testsuite/gfortran.dg/c_assoc_3.f90 Modified: branches/gcc-4_4-branch/gcc/fortran/ChangeLog branches/gcc-4_4-branch/gcc/fortran/symbol.c branches/gcc-4_4-branch/gcc/testsuite/ChangeLog
FIXED on the trunk (4.5) and the 4.4 branch. Thanks for the bug report!