Platform: Fedora release 7 (Moonshine) Linux idle.lbl.gov 2.6.22.9-91.fc7 #1 SMP Thu Sep 27 20:47:39 EDT 2007 x86_64 x86_64 x86_64 GNU/Linux % g++ -v Using built-in specs. Target: x86_64-unknown-linux-gnu Configured with: /net/rosie/scratch2/rwgk/gcc_trunk/configure --prefix=/net/cci-filer1/vol1/tmp/rwgk/gcc_trunk_130073_x86_64_fc7 --enable-languages=c,c++,fortran --with-mpfr=/usr Thread model: posix gcc version 4.3.0 20071110 (experimental) (GCC) I'll upload a small standalone reproducer. To reproduce the problem: % g++ -c -O1 ice_build2_stat.cpp ice_build2_stat.cpp: In function 'void foo()': ice_build2_stat.cpp:13: internal compiler error: in build2_stat, at tree.c:3115 Please submit a full bug report, with preprocessed source if appropriate. See <http://gcc.gnu.org/bugs.html> for instructions. It works with this alternative command: g++ -c ice_build2_stat.cpp It also works with many other compilers including all older g++. Ralf
Created attachment 14527 [details] reproducer
Confirmed. #1 0x00000000009a1c1e in build2_stat (code=POINTER_PLUS_EXPR, tt=0x2b9f0aa08e40, arg0=0x2b9f0ab5be80, arg1=0x2b9f0ab505a0) at ../../trunk/gcc/tree.c:3113 3113 gcc_assert (POINTER_TYPE_P (tt) && POINTER_TYPE_P (TREE_TYPE (arg0)) (gdb) call debug_generic_expr (arg0) ((long unsigned int) {1, +, 4294967295}_2 + 1) * 16 (gdb) call debug_generic_expr (arg1) p_32 #1 0x00000000009a1c1e in build2_stat (code=POINTER_PLUS_EXPR, tt=0x2b9f0aa08e40, arg0=0x2b9f0ab5be80, arg1=0x2b9f0ab505a0) at ../../trunk/gcc/tree.c:3113 #2 0x0000000000bed61d in chrec_fold_plus_1 (code=POINTER_PLUS_EXPR, type=0x2b9f0aa08e40, op0=0x2b9f0ab5be80, op1=0x2b9f0ab505a0) at ../../trunk/gcc/tree-chrec.c:321 #3 0x0000000000becdfe in chrec_apply (var=2, chrec=0x2b9f0ab58be0, x=0x2b9f0ab56720) at ../../trunk/gcc/tree-chrec.c:592 #4 0x000000000087d9d7 in compute_overall_effect_of_inner_loop ( loop=0x2b9f0ab531e0, evolution_fn=0x2b9f0ab58be0) at ../../trunk/gcc/tree-scalar-evolution.c:469 #5 0x000000000088358e in scev_const_prop () at ../../trunk/gcc/tree-scalar-evolution.c:2835
Either we should use correct order of arguments in chrec_evaluate (that function is swapping CHREC_LEFT based expression with CHREC_RIGHT based expression for pointer_plus addition) - testing patch for that - or chrec_fold_plus_1 should swap op0 with op1 if code is POINTER_PLUS_EXPR and the first argument has integer type, but second POINTER_TYPE_P.
(In reply to comment #3) > Either we should use correct order of arguments in chrec_evaluate (that > function > is swapping CHREC_LEFT based expression with CHREC_RIGHT based expression > for pointer_plus addition) - testing patch for that This is the correct fix. > - or chrec_fold_plus_1 > should swap op0 with op1 if code is POINTER_PLUS_EXPR and the first argument > has integer type, but second POINTER_TYPE_P. >
Subject: Bug 34063 Author: jakub Date: Tue Nov 13 18:23:03 2007 New Revision: 130151 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130151 Log: PR tree-optimization/34063 * tree-chrec.c (chrec_evaluate): Put CHREC_LEFT based argument as first chrec_fold_plus operand rather than second. * g++.dg/tree-ssa/pr34063.C: New test. Added: trunk/gcc/testsuite/g++.dg/tree-ssa/pr34063.C Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-chrec.c
Fixed.