Bug 32399 - [4.3 Regression] ICE in build2_stat, at tree.c:3074
Summary: [4.3 Regression] ICE in build2_stat, at tree.c:3074
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.3.0
: P1 normal
Target Milestone: 4.3.0
Assignee: Andrew Pinski
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2007-06-19 06:23 UTC by marcus
Modified: 2007-08-04 00:35 UTC (History)
3 users (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2007-06-21 23:11:26


Attachments
vertexbuffer.i (205 bytes, text/plain)
2007-06-19 06:24 UTC, marcus
Details

Note You need to log in before you can comment on or make changes to this bug.
Description marcus 2007-06-19 06:23:45 UTC
new regression, likely caused by pointer-plus branch merge

extracted from Wine

/home/marcus/projects/gcc/BIN/bin/gcc -m32   -O2   -c vertexbuffer.i 
vertexbuffer.i: In function 'f':
vertexbuffer.i:1: internal compiler error: in build2_stat, at tree.c:3074
Comment 1 marcus 2007-06-19 06:24:14 UTC
Created attachment 13734 [details]
vertexbuffer.i

gcc -O2 -c vertexbuffer.i
Comment 2 Andrew Pinski 2007-06-19 08:21:14 UTC
This is IV-opts going funny I think as we get pointer+pointer (and yes real pointer SSA_NAMES and no casts).
Comment 3 Andrew Pinski 2007-06-19 08:26:50 UTC
This code itself is very weird and I don't know if it is really defined or not.
We have basically:
char *f(char *a, char *b)
{
  return a + (int)b;
}

How can that even be defined.

Anyways the following fixes the problem:
Index: tree-ssa-address.c
===================================================================
--- tree-ssa-address.c  (revision 125776)
+++ tree-ssa-address.c  (working copy)
@@ -423,9 +423,9 @@
 
   /* Add ELT to base.  */
   type = TREE_TYPE (parts->base);
-  parts->base = fold_build2 (PLUS_EXPR, type,
+  parts->base = fold_build2 (POINTER_PLUS_EXPR, type,
                             parts->base,
-                            fold_convert (type, elt));
+                            fold_convert (sizetype, elt));
 }
 
 /* Finds the most expensive multiplication in ADDR that can be


Though I have not tested it at all.
Comment 4 Richard Biener 2007-06-19 09:17:04 UTC
The testcase indeed looks undefined (but valid).
Comment 5 marcus 2007-06-20 16:21:15 UTC
i have tested it and it works.

(i have also fixed the Wine code ;)
Comment 6 Andrew Pinski 2007-06-21 23:11:26 UTC
Mine.
Comment 7 Falk Hueffner 2007-06-27 15:37:25 UTC
This makes bootstrap fail on alphaev68-linux:

/src/gcc-2007.06.27/build/./gcc/xgcc -B/src/gcc-2007.06.27/build/./gcc/ -B/usr/local/alphaev68-unknown-linux-gnu/bin/ -B/usr/local/alphaev68-unknown-linux-gnu/lib/ -isystem /usr/local/alphaev68-unknown-linux-gnu/include -isystem /usr/local/alphaev68-unknown-linux-gnu/sys-include -g -fkeep-inline-functions -O2  -O2 -g -O2  -mieee -DIN_GCC    -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include  -fPIC -mieee -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED   -I. -I. -I../.././gcc -I../../../libgcc -I../../../libgcc/. -I../../../libgcc/../gcc -I../../../libgcc/../include  -o _gcov_execl.o -MT _gcov_execl.o -MD -MP -MF _gcov_execl.dep -DL_gcov_execl -c ../../../libgcc/../gcc/libgcov.c
../../../libgcc/../gcc/libgcov.c: In function '__gcov_execl':
../../../libgcc/../gcc/libgcov.c:838: internal compiler error: in build2_stat, at tree.c:3074
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make[3]: *** [_gcov_execl.o] Error 1
make[3]: Leaving directory `/src/gcc-2007.06.27/build/alphaev68-unknown-linux-gnu/libgcc'

This happens as soon as varargs are used:

$ cat test.c                                                                   
void f(int x, ...) {
    __builtin_va_list ap;
    __builtin_va_start(ap, x);
}
$ /src/gcc-2007.06.27/build/gcc/xgcc -B/src/gcc-2007.06.27/build/gcc/ -c test.c
test.c: In function 'f':
test.c:3: internal compiler error: in build2_stat, at tree.c:3074
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
Comment 8 pinskia@gmail.com 2007-06-27 15:41:21 UTC
Subject: Re:  [4.3 Regression] ICE in build2_stat, at tree.c:3074

On 27 Jun 2007 15:37:26 -0000, falk at debian dot org
<gcc-bugzilla@gcc.gnu.org> wrote:
>
>
> ------- Comment #7 from falk at debian dot org  2007-06-27 15:37 -------
> This makes bootstrap fail on alphaev68-linux:

This is a different bug, related to the alpha backend was not fix up
for pointer plus.
Please file seperately.

Thanks,
Andrew Pinski
Comment 9 Mark Mitchell 2007-06-29 18:49:56 UTC
Andrew, do you want to convert to sizetype or to ptrdiff_t?  Does it matter?
Comment 10 Andrew Pinski 2007-08-03 19:31:53 UTC
(In reply to comment #9)
> Andrew, do you want to convert to sizetype or to ptrdiff_t?  Does it matter?

sizetype is correct for POINTER_PLUS_EXPR.  We don't have a ptrdiff_t internally inside GCC as far as I know, only ssizetype (the signed version of sizetype).

I am testing this patch right now and should be done in about 2 hours.
Comment 11 Andrew Pinski 2007-08-04 00:33:45 UTC
Subject: Bug 32399

Author: pinskia
Date: Sat Aug  4 00:33:31 2007
New Revision: 127196

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=127196
Log:
2007-08-03  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        PR middle-end/32399
        * tree-ssa-address.c (add_to_parts): Use POINTER_PLUS_EXPR
        when adding to the base and convert ELT to sizetype instead of type.

2007-08-03  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        RP middle-end/32399
        * gcc.c-torture/compile/pr32399.c: New testcase.


Added:
    trunk/gcc/testsuite/gcc.c-torture/compile/pr32399.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-ssa-address.c

Comment 12 Andrew Pinski 2007-08-04 00:35:19 UTC
Fixed.