Bug 34063 - [4.3 Regression] ICE: build2_stat, at tree.c:3115
Summary: [4.3 Regression] ICE: build2_stat, at tree.c:3115
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.3.0
: P3 normal
Target Milestone: 4.3.0
Assignee: Jakub Jelinek
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2007-11-11 05:50 UTC by Ralf W. Grosse-Kunstleve
Modified: 2007-11-13 18:31 UTC (History)
4 users (show)

See Also:
Host: x86_64-unknown-linux-gnu
Target: x86_64-unknown-linux-gnu
Build: x86_64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2007-11-13 16:57:09


Attachments
reproducer (185 bytes, text/plain)
2007-11-11 05:53 UTC, Ralf W. Grosse-Kunstleve
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ralf W. Grosse-Kunstleve 2007-11-11 05:50:55 UTC
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
Comment 1 Ralf W. Grosse-Kunstleve 2007-11-11 05:53:02 UTC
Created attachment 14527 [details]
reproducer
Comment 2 Richard Biener 2007-11-11 12:26:15 UTC
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
Comment 3 Jakub Jelinek 2007-11-13 10:26:11 UTC
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.
Comment 4 Zdenek Dvorak 2007-11-13 17:34:03 UTC
(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.
> 

Comment 5 Jakub Jelinek 2007-11-13 18:23:14 UTC
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

Comment 6 Jakub Jelinek 2007-11-13 18:31:07 UTC
Fixed.