Bug 43303 - [4.4/4.5 Regression] ICE with C_ASSOCIATED
Summary: [4.4/4.5 Regression] ICE with C_ASSOCIATED
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.4.3
: P4 normal
Target Milestone: 4.4.4
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2010-03-09 10:25 UTC by Dennis Wassel
Modified: 2010-03-11 11:12 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2010-03-09 10:51:27


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dennis Wassel 2010-03-09 10:25:09 UTC
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
Comment 1 Dennis Wassel 2010-03-09 10:30:08 UTC
This looks like a 4.4.2 -> 4.4.3 regression.
It worls with 4.3.{2,3,4} and 4.4.2
Comment 2 Tobias Burnus 2010-03-09 10:51:27 UTC
Confirmed. Caused by the fix for PR 41777.
Comment 3 Tobias Burnus 2010-03-09 12:48:34 UTC
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);
Comment 4 Tobias Burnus 2010-03-10 18:57:03 UTC
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

Comment 5 Tobias Burnus 2010-03-11 11:10:51 UTC
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

Comment 6 Tobias Burnus 2010-03-11 11:12:35 UTC
FIXED on the trunk (4.5) and the 4.4 branch. Thanks for the bug report!