When the attached program is compiled by "gfortran bug061023.f90" I get an internal compiler error: > gfortran bug061023.f90 bug061023.f90: In function ‘phaml_restore’: bug061023.f90:15: internal compiler error: in gimplify_var_or_parm_decl, at gimplify.c:1665 The version is > gfortran --version GNU Fortran 95 (GCC) 4.3.0 20061023 (experimental)
Created attachment 12481 [details] this is the program that demonstrates the bug
This is on Linux Fedora Core 1 with a Linux binary download of gfortran.
Confirmed, reduced testcase: module hash_mod type element_t integer :: gid end type element_t type grid_type type(element_t), pointer :: element(:) end type grid_type contains subroutine hash_read_key(key) integer, intent(out) :: key(:) end subroutine hash_read_key subroutine phaml_restore(grid) type(grid_type) :: grid call hash_read_key(grid%element(1:1)%gid) call hash_read_key(grid%element(1:1)%gid) call hash_read_key(grid%element(1:1)%gid) end subroutine phaml_restore end module hash_mod ------- The problem is that in: atmp.0.data = (void *) &A.1; A.1 is not in the BIND_EXPRs at all.
Further reduced testcase, confirmed on ppc-darwin: type element_t integer :: gid end type element_t type(element_t) :: element(1) call hash_read_key(element%gid) call hash_read_key(element%gid) call hash_read_key(element%gid) contains subroutine hash_read_key(key) integer, intent(out) :: key(1) end subroutine hash_read_key end I'll also note that the following slightly modified testcase segfaults: type element_t integer :: gid end type element_t contains subroutine hash_read_key(key) integer, intent(out) :: key(1) end subroutine hash_read_key type(element_t) :: element(1) call hash_read_key(element%gid) call hash_read_key(element%gid) call hash_read_key(element%gid) end Program received signal SIGSEGV, Segmentation fault. 0x0805b323 in variable_decl (elem=Variable "elem" is not available. ) at ../../../trunk/gcc/fortran/decl.c:1424 1424 if (current_ts.type == BT_DERIVED (gdb) where #0 0x0805b323 in variable_decl (elem=Variable "elem" is not available. ) at ../../../trunk/gcc/fortran/decl.c:1424 #1 0x0805bcbc in gfc_match_data_decl () at ../../../trunk/gcc/fortran/decl.c:3381 #2 0x0808716a in match_word (str=Variable "str" is not available. ) at ../../../trunk/gcc/fortran/parse.c:66 #3 0x0808770d in decode_statement () at ../../../trunk/gcc/fortran/parse.c:135 #4 0x0808809e in next_statement () at ../../../trunk/gcc/fortran/parse.c:499 #5 0x0808a3cd in parse_contained (module=0) at ../../../trunk/gcc/fortran/parse.c:2796
This fixes it but has not been regtested. I was hoping to have found a slightly cleaner way to fix this but did not alight on anything that would not be a big performance. It's OK for rank 1 arrays but for rank 2 or higher, carries baggage in the form of various other declarations from the loopinfo that was never used. Index: gcc/fortran/trans-expr.c =================================================================== *** gcc/fortran/trans-expr.c (revision 117860) --- gcc/fortran/trans-expr.c (working copy) *************** gfc_conv_aliased_arg (gfc_se * parmse, g *** 1708,1716 **** } else { ! /* Make sure that the temporary declaration survives. */ ! tmp = gfc_finish_block (&body); ! gfc_add_expr_to_block (&loop.pre, tmp); } /* Add the post block after the second loop, so that any --- 1708,1721 ---- } else { ! /* Make sure that the temporary declaration survives by merging ! all the loop declarations into the current context. */ ! for (n = 0; n < loop.dimen; n++) ! { ! gfc_merge_block_scope (&body); ! body = loop.code[loop.order[n]]; ! } ! gfc_merge_block_scope (&body); } /* Add the post block after the second loop, so that any Paul
I will submit the above patch tomorrow, time permitting (I am on the road right now.). Paul
Subject: Bug 29565 Author: pault Date: Sun Nov 5 06:27:48 2006 New Revision: 118492 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118492 Log: 2006-11-05 Francois-Xavier Coudert <fxcoudert@gcc.gnu,org> Paul Thomas <pault@gcc.gnu.org> PR fortran/24518 * trans-intrinsic.c (gfc_conv_intrinsic_mod): Use built_in fmod for both MOD and MODULO, if it is available. PR fortran/29565 * trans-expr.c (gfc_conv_aliased_arg): For an INTENT(OUT), save the declarations from the unused loops by merging the block scope for each; this ensures that the temporary is declared. 2006-11-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/29565 * gfortran.dg/gfortran.dg/aliasing_dummy_3.f90: New test. Added: trunk/gcc/testsuite/gfortran.dg/aliasing_dummy_3.f90 Modified: trunk/gcc/fortran/ChangeLog trunk/gcc/fortran/f95-lang.c trunk/gcc/fortran/trans-expr.c trunk/gcc/fortran/trans-intrinsic.c trunk/gcc/testsuite/ChangeLog
Subject: Bug 29565 Author: pault Date: Sun Nov 5 08:46:02 2006 New Revision: 118493 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118493 Log: 2006-11-05 Francois-Xavier Coudert <fxcoudert@gcc.gnu,org> Paul Thomas <pault@gcc.gnu.org> PR fortran/24518 * trans-intrinsic.c (gfc_conv_intrinsic_mod): Use built_in fmod for both MOD and MODULO, if it is available. 2006-11-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/29565 * trans-expr.c (gfc_conv_aliased_arg): For an INTENT(OUT), save the declarations from the unused loops by merging the block scope for each; this ensures that the temporary is declared. PR fortran/29387 * trans-intrinsic.c (gfc_conv_intrinsic_len): Rearrange to have a specific case for EXPR_VARIABLE and, in default, build an ss to call gfc_conv_expr_descriptor for array expressions.. PR fortran/29490 * trans-expr.c (gfc_set_interface_mapping_bounds): In the case that GFC_TYPE_ARRAY_LBOUND is not available, use descriptor values for it and GFC_TYPE_ARRAY_UBOUND. PR fortran/29641 * trans-types.c (gfc_get_derived_type): If the derived type namespace has neither a parent nor a proc_name, set NULL for the search namespace. 2006-11-05 Paul Thomas <pault@gcc.gnu.org> PR fortran/29565 * gfortran.dg/gfortran.dg/aliasing_dummy_3.f90: New test. PR fortran/29387 * gfortran.dg/intrinsic_actual_2.f90: New test. PR fortran/29490 * gfortran.dg/actual_array_interface_1.f90: New test. PR fortran/29641 * gfortran.dg/used_types_11.f90: New test. Added: branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/actual_array_interface_1.f90 branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/aliasing_dummy_3.f90 branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/intrinsic_actual_2.f90 branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/used_types_11.f90 Modified: branches/gcc-4_2-branch/gcc/fortran/ChangeLog branches/gcc-4_2-branch/gcc/fortran/f95-lang.c branches/gcc-4_2-branch/gcc/fortran/trans-expr.c branches/gcc-4_2-branch/gcc/fortran/trans-intrinsic.c branches/gcc-4_2-branch/gcc/fortran/trans-types.c branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
Subject: Bug number PR29565 A patch for this bug has been added to the patch tracker. The mailing list url for the patch is http://gcc.gnu.org/ml/gcc-patches/2006-11/msg00038.html
Fixed on trunk and 4.2 - soo to be fixed on 4.1. Paul
Subject: Bug 29565 Author: pault Date: Fri Nov 10 21:52:00 2006 New Revision: 118666 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118666 Log: 2006-11-10 Paul Thomas <pault@gcc.gnu.org> Backport from mainline. PR fortran/29371 * trans-expr.c (gfc_trans_pointer_assignment): Add the expression for the assignment of null to the data field to se->pre, rather than block. PR fortran/29392 * data.c (create_character_intializer): Copy and simplify the expressions for the start and end of a sub-string reference. PR fortran/29216 PR fortran/29314 * gfortran.h : Add EXEC_INIT_ASSIGN. * dump-parse-tree.c (gfc_show_code_node): The same. * trans-expr.c (gfc_trans_init_assign): New function. * trans-stmt.h : Add prototype for gfc_trans_init_assign. * trans.c (gfc_trans_code): Implement EXEC_INIT_ASSIGN. * resolve.c (resolve_allocate_exp): Replace EXEC_ASSIGN by EXEC_INIT_ASSIGN. (resolve_code): EXEC_INIT_ASSIGN does not need resolution. (apply_default_init): New function. (resolve_symbol): Call it for derived types that become defined but which do not already have an initialization expression.. * st.c (gfc_free_statement): Include EXEC_INIT_ASSIGN. PR fortran/29387 * trans-intrinsic.c (gfc_conv_intrinsic_len): Rearrange to have a specific case for EXPR_VARIABLE and, in default, build an ss to call gfc_conv_expr_descriptor for array expressions.. PR fortran/29490 * trans-expr.c (gfc_set_interface_mapping_bounds): In the case that GFC_TYPE_ARRAY_LBOUND is not available, use descriptor values for it and GFC_TYPE_ARRAY_UBOUND. PR fortran/29641 * trans-types.c (gfc_get_derived_type): If the derived type namespace has neither a parent nor a proc_name, set NULL for the search namespace. PR fortran/24518 * trans-intrinsic.c (gfc_conv_intrinsic_mod): Use built_in fmod for both MOD and MODULO, if it is available. PR fortran/29565 * trans-expr.c (gfc_conv_aliased_arg): For an INTENT(OUT), save the declarations from the unused loops by merging the block scope for each; this ensures that the temporary is declared. 2006-11-10 Paul Thomas <pault@gcc.gnu.org> PR fortran/29371 * gfortran.dg/nullify_3.f90: New test. PR fortran/29392 * gfortran.dg/data_char_3.f90: New test. PR fortran/29216 * gfortran.dg/result_default_init_1.f90: New test. PR fortran/29314 * gfortran.dg/automatic_default_init_1.f90: New test. PR fortran/29387 * trans-intrinsic.c (gfc_conv_intrinsic_len): Rearrange to have a specific case for EXPR_VARIABLE and, in default, build an ss to call gfc_conv_expr_descriptor for array expressions.. PR fortran/29490 * trans-expr.c (gfc_set_interface_mapping_bounds): In the case that GFC_TYPE_ARRAY_LBOUND is not available, use descriptor values for it and GFC_TYPE_ARRAY_UBOUND. PR fortran/29641 * trans-types.c (gfc_get_derived_type): If the derived type namespace has neither a parent nor a proc_name, set NULL for the search namespace. PR fortran/29565 * gfortran.dg/gfortran.dg/aliasing_dummy_3.f90: New test. Added: branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/actual_array_interface_1.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/aliasing_dummy_3.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/automatic_default_init_1.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/data_char_3.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/intrinsic_actual_2.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/nullify_3.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/result_default_init_1.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/used_types_11.f90 branches/gcc-4_1-branch/gcc/testsuite/gfortran.dg/used_types_12.f90 Modified: branches/gcc-4_1-branch/gcc/fortran/ChangeLog branches/gcc-4_1-branch/gcc/fortran/data.c branches/gcc-4_1-branch/gcc/fortran/dump-parse-tree.c branches/gcc-4_1-branch/gcc/fortran/f95-lang.c branches/gcc-4_1-branch/gcc/fortran/gfortran.h branches/gcc-4_1-branch/gcc/fortran/resolve.c branches/gcc-4_1-branch/gcc/fortran/st.c branches/gcc-4_1-branch/gcc/fortran/trans-expr.c branches/gcc-4_1-branch/gcc/fortran/trans-intrinsic.c branches/gcc-4_1-branch/gcc/fortran/trans-stmt.h branches/gcc-4_1-branch/gcc/fortran/trans-types.c branches/gcc-4_1-branch/gcc/fortran/trans.c branches/gcc-4_1-branch/gcc/testsuite/ChangeLog