The following fails with today's (rev. 120520) trunk (at -O1 on both i686-linux and x86_64-linux): $ cat mc_coordinates.f90 SUBROUTINE check_for_overlap (cell_length) REAL, DIMENSION(1:3), INTENT(IN), OPTIONAL :: cell_length REAL, DIMENSION(1:3) :: abc, box_length IF (PRESENT(cell_length)) THEN box_length(1:3)=abc(1:3) ENDIF END SUBROUTINE check_for_overlap $ gfortran -O1 -c mc_coordinates.f90 mc_coordinates.f90: In function ‘check_for_overlap’: mc_coordinates.f90:6: internal compiler error: in operand_equal_p, at fold-const.c:2539 The bug was originaly reported in PR29975. The gdb backtrace is: Breakpoint 1, fancy_abort (file=0xa20a04 "../../trunk/gcc/fold-const.c", line=2539, function=0xa20900 "operand_equal_p") at ../../trunk/gcc/diagnostic.c:641 641 { (gdb) back #0 fancy_abort (file=0xa20a04 "../../trunk/gcc/fold-const.c", line=2539, function=0xa20900 "operand_equal_p") at ../../trunk/gcc/diagnostic.c:641 #1 0x00000000005c416d in operand_equal_p (arg0=0x2a984c3e40, arg1=0x2a983e3300, flags=0) at ../../trunk/gcc/fold-const.c:2539 #2 0x00000000005c7f5f in fold_ternary (code=COND_EXPR, type=0x2a983f30c0, op0=0x2a983de3c0, op1=0x2a984c3e40, op2=0x2a983e3300) at ../../trunk/gcc/fold-const.c:11657 #3 0x00000000005c9161 in fold_build3_stat (code=COND_EXPR, type=0x2a983f30c0, op0=0x2a983de3c0, op1=0x2a984c3e40, op2=0x2a983e3300) at ../../trunk/gcc/fold-const.c:12307 #4 0x0000000000493271 in gfc_trans_if_1 (code=0xd6af60) at ../../trunk/gcc/fortran/trans-stmt.c:612 #5 0x0000000000464b83 in gfc_trans_code (code=0xd73b80) at ../../trunk/gcc/fortran/trans.c:528 #6 0x0000000000477f64 in gfc_generate_function_code (ns=0xd6a710) at ../../trunk/gcc/fortran/trans-decl.c:3232 #7 0x0000000000442bfc in gfc_parse_file () at ../../trunk/gcc/fortran/parse.c:3263 I don't see any suspicious change in gcc/fortran/ChangeLog, maybe it has to do with Roger's recent array copying patch (although I don't see how). What is sure is that it worked at least until 20070104, and is now failing. Roger, could you give it a look?
This is a bug exposed by Roger's memcpy patch. This bug was originally caused by Aldy's GIMPLE_MODIFY_STMT patch. We are trying to fold a conditional expression's whos one side is a GIMPLE_MODIFY_STMT that came from folding of memcpy.
*** Bug 30412 has been marked as a duplicate of this bug. ***
Aldy, can you comment on this bug? It's still present as of today, and it prevents mainline from building a fair number of real-life Fortran codes.
I'll look at this.
*** Bug 30672 has been marked as a duplicate of this bug. ***
a patch: http://gcc.gnu.org/ml/gcc-patches/2007-02/msg00353.html
*** Bug 30715 has been marked as a duplicate of this bug. ***
Testing of the CALL_EXPR representation patch turned up a related ICE in tree_ssa_useless_type_conversion() while compiling libjava/java/lang/reflect/natMethod.cc. It was failing because the expansion of memcpy produced by fold_builtin_memory_op includes a GIMPLE_MODIFY_STMT, and expansion of builtins happens long before the gimplifier is invoked by the C++ front end. See http://gcc.gnu.org/ml/gcc-patches/2007-02/msg01193.html for more discussion. As a temporary solution, the CALL_EXPR patch includes a tweak to use GENERIC_TREE_TYPE in tree_ssa_useless_type_conversion(). This should be revisited as part of a general solution.
I believe this is addressed by Roger's patch which was approved yesterday (http://gcc.gnu.org/ml/gcc-patches/2007-02/msg00353.html), though I don't think the final revision has been committed.
Subject: Bug 30391 Author: sayle Date: Fri Feb 16 03:38:22 2007 New Revision: 122030 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=122030 Log: PR middle-end/30391 * tree.c (expr_align): Handle MODIFY_EXPR. GIMPLE_MODIFY_STMT should be unreachable. (build2_stat): Allow construction of MODIFY_EXPR at any time. For the time being redirect GIMPLE_MODIFY_STMT to the new (renamed) build_gimple_modify_stmt_stat. (build2_gimple_stat): Rename to... (build_gimple_modify_stmt_stat): Now longer take a CODE argument. Always build a GIMPLE_MODIFY_STMT node. * tree.h (build2_gimple, build2_gimple_stat): Delete. (build_gimple_modify_stmt, build_gimple_modify_stmt_stat): New declarations. * tree-cfg.c (factor_computed_gotos, tree_merge_blocks, gimplify_val): Use build_gimple_modify_stmt instead of build2_gimple. * tree-complex.c (set_component_ssa_name, expand_complex_move, expand_complex_div_wide): Likewise. * tree-ssa-dom.c (record_equivalences_from_stmt): Likewise. * tree-ssa-loop-im.c (schedule_sm): Likewise. * tree-ssa-loop-ivopts.c (rewrite_use_nonlinear_expr): Likewise. * tree-ssa-loop-manip.c (create_iv): Likewise. * tree-ssa-phiopt.c (conditional_replacement, minmax_replacement, abs_replacement): Likewise. * tree-ssa-pre.c (create_expression_by_pieces, poolify_modify_stmt, realify_fake_stores): Likewise. * builtins.c (std_expand_builtin_va_start): Build a MODIFY_EXPR node rather than a GIMPLE_MODIFY_STMT node. (std_gimpify_va_arg_expr, expand_builtin_va_copy, fold_builtin_memset, fold_builtin_memory_op, do_mpfr_sincos): Likewise. (integer_valued_real_p): Handle MODIFY_EXPR, not GIMPLE_MODIFY_STMT. * expr.c (expand_expr_real_1): Handle both MODIFY_EXPR and GIMPLE_MODIFY_STMT. * gfortran.dg/pr30391-1.f90: New test case. Added: trunk/gcc/testsuite/gfortran.dg/pr30391-1.f90 Modified: trunk/gcc/ChangeLog trunk/gcc/builtins.c trunk/gcc/expr.c trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-cfg.c trunk/gcc/tree-complex.c trunk/gcc/tree-ssa-dom.c trunk/gcc/tree-ssa-loop-im.c trunk/gcc/tree-ssa-loop-ivopts.c trunk/gcc/tree-ssa-loop-manip.c trunk/gcc/tree-ssa-phiopt.c trunk/gcc/tree-ssa-pre.c trunk/gcc/tree.c trunk/gcc/tree.h
*** Bug 30817 has been marked as a duplicate of this bug. ***
Fixed.