https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69742
Bug ID: 69742 Summary: ICE with -O3 and ASSOCIATE containing repeated expression Product: gcc Version: 6.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran Assignee: unassigned at gcc dot gnu.org Reporter: mrestelli at gmail dot com Target Milestone: --- This code produces and internal compiler error when compiled with -O3. It seems that the problem is the appearance of the same expression twice inside the associate construct. The code compiles and runs without optimization. program p implicit none integer, allocatable :: i(:), j allocate( i(5) ) i = (/( j , j=1,5 )/) ! The ICE appears when "size(i)" is used twice in associate associate( i5 => i(size(i):size(i)) ) ! this gives ICE !associate( i5 => i(size(2*i):size(i)) ) ! this works i5 = 2 end associate write(*,*) i end program p $ gfortran -O3 test.f90 -o test test.f90:11:0: i5 = 2 internal compiler error: in gimplify_var_or_parm_decl, bei gimplify.c:1840 0x86e434 gimplify_var_or_parm_decl gcc/gimplify.c:1840 0x872051 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) gcc/gimplify.c:10595 0x8719cc gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) gcc/gimplify.c:10455 0x87b680 gimplify_modify_expr gcc/gimplify.c:4709 0x872210 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) gcc/gimplify.c:10162 0x874c46 gimplify_stmt(tree_node**, gimple**) gcc/gimplify.c:5642 0x87339b gimplify_statement_list gcc/gimplify.c:1526 0x87339b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) gcc/gimplify.c:10579 0x874c46 gimplify_stmt(tree_node**, gimple**) gcc/gimplify.c:5642 0x8756bd gimplify_bind_expr gcc/gimplify.c:1142 0x871d42 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) gcc/gimplify.c:10361 0x874c46 gimplify_stmt(tree_node**, gimple**) gcc/gimplify.c:5642 0x87339b gimplify_statement_list gcc/gimplify.c:1526 0x87339b gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) gcc/gimplify.c:10579 0x874c46 gimplify_stmt(tree_node**, gimple**) gcc/gimplify.c:5642 0x872952 gimplify_and_add(tree_node*, gimple**) gcc/gimplify.c:425 0x872952 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) gcc/gimplify.c:10501 0x874c46 gimplify_stmt(tree_node**, gimple**) gcc/gimplify.c:5642 0x8756bd gimplify_bind_expr gcc/gimplify.c:1142 0x871d42 gimplify_expr(tree_node**, gimple**, gimple**, bool (*)(tree_node*), int) gcc/gimplify.c:10361 $ gfortran --version GNU Fortran (GCC) 6.0.0 20160209 (experimental)