http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52469
Tobias Burnus <burnus at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pault at gcc dot gnu.org --- Comment #4 from Tobias Burnus <burnus at gcc dot gnu.org> 2012-03-05 20:31:58 UTC --- WITH -fno-whole-file: (gdb) b trans-expr.c:2249 ... Breakpoint 1, get_proc_ptr_comp (e=0x16d6420) at /projects/tob/gcc-git/gcc/gcc/fortran/trans-expr.c:2249 2249 e2->expr_type = old_type; (gdb) p debug_tree (comp_se.expr->typed.type) <function_type 0x2aaaacfb8b28 type <real_type 0x2aaaacea1e70 real(kind=4) SF WITH -fwhole-file: (gdb) p debug_tree (comp_se.expr->typed.type) <pointer_type 0x2aaaacfb8bd0 type <function_type 0x2aaaacfb8b28 type <real_type 0x2aaaacea1e70 real(kind=4) SF * * * Ignoring the difference, I tried: --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -2250,2 +2250,4 @@ get_proc_ptr_comp (gfc_expr *e) gfc_free_expr (e2); + if (POINTER_TYPE_P (TREE_TYPE (comp_se.expr))) + return comp_se.expr; return build_fold_addr_expr_loc (input_location, comp_se.expr); However, that leads to a segfault at run time in the WRITE line - even though the dump looks OK: real(kind=4) D.1871; static real(kind=4) C.1870 = 3.0e+0; D.1871 = newtype[1].my_f_ptr (&C.1870); _gfortran_transfer_real_write (&dt_parm.0, &D.1871, 4); * * * I tried to find out what's the difference between -f(no-)whole file, but so far without success. "gfc_get_ppc_type" is in both cases only called once and returns a <pointer_type 0x2aaaacfb8bd0 type <function_type 0x2aaaacfb8b28 Once, it is called directly: gfc_get_symbol_decl -> gfc_sym_type -> gfc_typenode_for_spec -> gfc_get_derived_type And once indirectly: gfc_get_symbol_decl -> gfc_sym_type -> gfc_typenode_for_spec -> gfc_get_derived_type -> gfc_get_module_backend_decl -> gfc_get_derived_type