The current trunk gives an ICE when a procedure contains a “do concurrent” and an internal subprogram: $ cat doconcurrent.f90 subroutine ice_with_gfortran49() integer i do concurrent (i=1:2) end do contains subroutine f() end subroutine end subroutine $ gfortran -c doconcurrent.f90 doconcurrent.f90: In function 'ice_with_gfortran49': doconcurrent.f90:1:0: internal compiler error: Segmentation fault: 11 subroutine ice_with_gfortran49() ^ doconcurrent.f90:1:0: internal compiler error: Abort trap: 6 gfortran: internal compiler error: Abort trap: 6 (program f951) Abort trap: 6 localhost:gnu rouson$ gfortran --version GNU Fortran (MacPorts gcc49 4.9-20140105_0) 4.9.0 20140105 (experimental) ———— gfortran 4.8.2 compiles the above code without error. Damian
The test compiles with r204000 (2013-10-24) and gives an ICE with r204945 (2013-11-18). The backtrace with r206348 is Program received signal SIGSEGV, Segmentation fault. get_chain_decl (info=0x143003dc0) at ../../_clean/gcc/tree-nested.c:234 234 tree type = info->frame_type; (gdb) bt #0 get_chain_decl (info=0x143003dc0) at ../../_clean/gcc/tree-nested.c:234 #1 0x00000001007c896d in get_nonlocal_debug_decl (info=0x143003dc0, decl=0x1433444c0) at ../../_clean/gcc/tree-nested.c:851 #2 0x00000001007c8bc9 in convert_nonlocal_reference_op (tp=0x143344658, walk_subtrees=<optimized out>, data=0x7fff5fbff170) at ../../_clean/gcc/tree-nested.c:934 #3 0x000000010094a406 in walk_tree_1 (tp=<optimized out>, func=<optimized out>, data=<optimized out>, pset=<optimized out>, lh=<optimized out>) at ../../_clean/gcc/tree.c:10925 #4 0x000000010053751f in walk_gimple_op (stmt=<optimized out>, callback_op=0x1007c8ab0 <convert_nonlocal_reference_op(tree*, int*, void*)>, wi=0x7fff5fbff170) at ../../_clean/gcc/gimple-walk.c:267 #5 0x0000000100537e85 in walk_gimple_stmt (gsi=0x7fff5fbfef70, callback_stmt=0x1007c90c0 <convert_nonlocal_reference_stmt(gimple_stmt_iterator*, bool*, walk_stmt_info*)>, callback_op=0x1007c8ab0 <convert_nonlocal_reference_op(tree*, int*, void*)>, wi=0x7fff5fbff170) at ../../_clean/gcc/gimple-walk.c:535 #6 0x00000001005380f1 in walk_gimple_seq_mod (pseq=<optimized out>, callback_stmt=0x1007c90c0 <convert_nonlocal_reference_stmt(gimple_stmt_iterator*, bool*, walk_stmt_info*)>, callback_op=0x1007c8ab0 <convert_nonlocal_reference_op(tree*, int*, void*)>, wi=0x7fff5fbff170) at ../../_clean/gcc/gimple-walk.c:58 #7 0x0000000100537fd3 in walk_gimple_stmt (gsi=0x7fff5fbff000, callback_stmt=0x1007c90c0 <convert_nonlocal_reference_stmt(gimple_stmt_iterator*, bool*, walk_stmt_info*)>, callback_op=0x1007c8ab0 <convert_nonlocal_reference_op(tree*, int*, void*)>, wi=0x7fff5fbff170) at ../../_clean/gcc/gimple-walk.c:545 #8 0x00000001005380f1 in walk_gimple_seq_mod (pseq=<optimized out>, callback_stmt=0x1007c90c0 <convert_nonlocal_reference_stmt(gimple_stmt_iterator*, bool*, walk_stmt_info*)>, callback_op=0x1007c8ab0 <convert_nonlocal_reference_op(tree*, int*, void*)>, wi=0x7fff5fbff170) at ../../_clean/gcc/gimple-walk.c:58 #9 0x0000000100537fd3 in walk_gimple_stmt (gsi=0x7fff5fbff090, callback_stmt=0x1007c90c0 <convert_nonlocal_reference_stmt(gimple_stmt_iterator*, bool*, walk_stmt_info*)>, callback_op=0x1007c8ab0 <convert_nonlocal_reference_op(tree*, int*, void*)>, wi=0x7fff5fbff170) at ../../_clean/gcc/gimple-walk.c:545 #10 0x00000001005380f1 in walk_gimple_seq_mod (pseq=<optimized out>, callback_stmt=0x1007c90c0 <convert_nonlocal_reference_stmt(gimple_stmt_iterator*, bool*, walk_stmt_info*)>, callback_op=0x1007c8ab0 <convert_nonlocal_reference_op(tree*, int*, void*)>, wi=0x7fff5fbff170) at ../../_clean/gcc/gimple-walk.c:58 #11 0x0000000100537fd3 in walk_gimple_stmt (gsi=0x7fff5fbff120, callback_stmt=0x1007c90c0 <convert_nonlocal_reference_stmt(gimple_stmt_iterator*, bool*, walk_stmt_info*)>, callback_op=0x1007c8ab0 <convert_nonlocal_reference_op(tree*, int*, void*)>, wi=0x7fff5fbff170) at ../../_clean/gcc/gimple-walk.c:545 #12 0x00000001005380f1 in walk_gimple_seq_mod (pseq=<optimized out>, callback_stmt=0x1007c90c0 <convert_nonlocal_reference_stmt(gimple_stmt_iterator*, bool*, walk_stmt_info*)>, callback_op=0x1007c8ab0 <convert_nonlocal_reference_op(tree*, int*, void*)>, wi=0x7fff5fbff170) at ../../_clean/gcc/gimple-walk.c:58 #13 0x00000001007c7412 in walk_body (callback_stmt=<optimized out>, callback_op=<optimized out>, info=<optimized out>, pseq=<optimized out>) at ../../_clean/gcc/tree-nested.c:603 #14 0x00000001007c940f in walk_all_functions ( callback_stmt=0x1007c90c0 <convert_nonlocal_reference_stmt(gimple_stmt_iterator*, bool*, walk_stmt_info*)>, callback_op=0x1007c8ab0 <convert_nonlocal_reference_op(tree*, int*, void*)>, root=<optimized out>) at ../../_clean/gcc/tree-nested.c:614 #15 0x00000001007ca812 in lower_nested_functions (fndecl=0x14334ae00) at ../../_clean/gcc/tree-nested.c:2675 #16 0x00000001003e115f in analyze_function (node=<optimized out>) at ../../_clean/gcc/cgraphunit.c:656 #17 0x00000001003e23b8 in analyze_functions () at ../../_clean/gcc/cgraphunit.c:1017 #18 0x00000001003e34f3 in finalize_compilation_unit () at ../../_clean/gcc/cgraphunit.c:2310 #19 0x000000010060ddb0 in write_global_declarations () at ../../_clean/gcc/langhooks.c:323 #20 0x0000000100754531 in compile_file () at ../../_clean/gcc/toplev.c:561 #21 0x0000000100756369 in toplev_main (argc=2, argv=0x7fff5fbff520) at ../../_clean/gcc/toplev.c:1887
The same ICE occurs when putting it into the main program: integer i do concurrent (i=1:2) end do contains subroutine f end end Backtrace: internal compiler error: Segmentation fault integer i ^ 0x940f4f crash_signal /home/jweil/gcc49/trunk/gcc/toplev.c:336 0x99df9a get_frame_type /home/jweil/gcc49/trunk/gcc/tree-nested.c:234 0x99df9a get_chain_decl /home/jweil/gcc49/trunk/gcc/tree-nested.c:342 0x99efdc get_chain_decl /home/jweil/gcc49/trunk/gcc/tree-nested.c:851 0x99efdc get_nonlocal_debug_decl /home/jweil/gcc49/trunk/gcc/tree-nested.c:856 0x99f218 convert_nonlocal_reference_op /home/jweil/gcc49/trunk/gcc/tree-nested.c:934 0xaf84ab walk_tree_1(tree_node**, tree_node* (*)(tree_node**, int*, void*), void*, pointer_set_t*, tree_node* (*)(tree_node**, int*, tree_node* (*)(tree_node**, int*, void*), void*, pointer_set_t*)) /home/jweil/gcc49/trunk/gcc/tree.c:10925 0x7c9d55 walk_gimple_op(gimple_statement_base*, tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*) /home/jweil/gcc49/trunk/gcc/gimple-walk.c:267 0x7ca4c4 walk_gimple_stmt(gimple_stmt_iterator*, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*) /home/jweil/gcc49/trunk/gcc/gimple-walk.c:535 0x7ca678 walk_gimple_seq_mod(gimple_statement_base**, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*) /home/jweil/gcc49/trunk/gcc/gimple-walk.c:58 0x7ca572 walk_gimple_stmt(gimple_stmt_iterator*, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*) /home/jweil/gcc49/trunk/gcc/gimple-walk.c:545 0x7ca678 walk_gimple_seq_mod(gimple_statement_base**, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*) /home/jweil/gcc49/trunk/gcc/gimple-walk.c:58 0x7ca572 walk_gimple_stmt(gimple_stmt_iterator*, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*) /home/jweil/gcc49/trunk/gcc/gimple-walk.c:545 0x7ca678 walk_gimple_seq_mod(gimple_statement_base**, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*) /home/jweil/gcc49/trunk/gcc/gimple-walk.c:58 0x7ca572 walk_gimple_stmt(gimple_stmt_iterator*, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*) /home/jweil/gcc49/trunk/gcc/gimple-walk.c:545 0x7ca678 walk_gimple_seq_mod(gimple_statement_base**, tree_node* (*)(gimple_stmt_iterator*, bool*, walk_stmt_info*), tree_node* (*)(tree_node**, int*, void*), walk_stmt_info*) /home/jweil/gcc49/trunk/gcc/gimple-walk.c:58 0x99e0a1 walk_body /home/jweil/gcc49/trunk/gcc/tree-nested.c:603 0x99f8b8 walk_function /home/jweil/gcc49/trunk/gcc/tree-nested.c:614 0x99f8b8 walk_all_functions /home/jweil/gcc49/trunk/gcc/tree-nested.c:679 0x9a098f lower_nested_functions(tree_node*) /home/jweil/gcc49/trunk/gcc/tree-nested.c:2675
r204463 (2013-11-06) gives the ICE.
Might be least caused by my IVDEP patch, i.e. r204021 (middle-end part) and r204023 (FE part), which fits revision wise.
Created attachment 31874 [details] gcc49-pr59706.patch Untested fix. create_tmp_var_raw doesn't do tons of needed things, like (for this testcase most important) doesn't set DECL_CONTEXT. On the other side, create_tmp_var_raw will ICE if the type isn't complete or needs constructing/destructing, but in that case we don't want to create the temporary anyway, that will typically (always?) be just an already reported bug.
Author: jakub Date: Fri Jan 17 20:55:42 2014 New Revision: 206732 URL: http://gcc.gnu.org/viewcvs?rev=206732&root=gcc&view=rev Log: PR middle-end/59706 * gimplify.c (gimplify_expr): Use create_tmp_var instead of create_tmp_var_raw. If cond doesn't have integral type, don't add the IFN_ANNOTATE builtin at all. * gfortran.dg/pr59706.f90: New test. * g++.dg/ext/pr59706.C: New test. Added: trunk/gcc/testsuite/g++.dg/ext/pr59706.C trunk/gcc/testsuite/gfortran.dg/pr59706.f90 Modified: trunk/gcc/ChangeLog trunk/gcc/gimplify.c trunk/gcc/testsuite/ChangeLog
Fixed.