Bug 11207 - [3.3/3.4 regression] ICE with negative index in array element designator
Summary: [3.3/3.4 regression] ICE with negative index in array element designator
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.2.3
: P1 normal
Target Milestone: 3.3.2
Assignee: Mark Mitchell
URL:
Keywords: ice-on-invalid-code, monitored
: 11333 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-06-16 10:37 UTC by etienne.lorrain
Modified: 2004-01-17 04:22 UTC (History)
4 users (show)

See Also:
Host: i386 Linux
Target: i386 Linux
Build: i386 Linux
Known to work:
Known to fail:
Last reconfirmed: 2003-08-03 17:32:22


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description etienne.lorrain 2003-06-16 10:37:39 UTC
etienne@fulbert:~/projet/gujin$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-linux/3.2.3/specs
Configured with: ../src/configure -v --enable-languages=c,c++,f77,objc,ada --
prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-gxx-
include-dir=/usr/include/c++/3.2 --enable-shared --with-system-zlib --enable-
nls --without-included-gettext --enable-__cxa_atexit --enable-clocale=gnu --
enable-objc-gc i386-linux
Thread model: posix
gcc version 3.2.3 (Debian)
etienne@fulbert:~/projet/gujin$ cat f.c
#define _ 0
#define X 1
#define B(p0, p1, p2, p3, p4, p5, p6, p7) \
        {{p7, p6, p5, p4, p3, p2, p1, p0}}

union font_line_u {
      struct {
        unsigned char b0 :1, b1 :1, b2 :1, b3 :1, b4 :1, b5 :1, b6 :1, b7 :1;
        } __attribute__ ((packed)) bit;
      unsigned char group;
      } __attribute__ ((packed));

const union font_line_u font8x8[256][8] = {
      ['e'] = {
        B (_,_,_,_,_,_,_,_),
        B (_,_,_,_,_,_,_,_),
        B (_,_,_,X,_,_,_,_),
        B (_,_,X,_,X,_,_,_),
        B (_,_,X,X,_,_,_,_),
        B (_,_,X,_,_,_,_,_),
        B (_,_,_,X,X,_,_,_),
        B (_,_,_,_,_,_,_,_),
        },
      ['รจ'] = { /* e grave */
        B (_,_,_,X,_,_,_,_),
        B (_,_,_,_,X,_,_,_),
        B (_,_,_,X,_,X,_,_),
        B (_,_,X,_,X,_,_,_),
        B (_,_,X,X,_,_,_,_),
        B (_,_,X,_,_,_,_,_),
        B (_,_,_,X,X,_,_,_),
        B (_,_,_,_,_,_,_,_),
        },
        };
etienne@fulbert:~/projet/gujin$ gcc -c f.c -funsigned-char
etienne@fulbert:~/projet/gujin$ gcc -c f.c
f.c:24: Internal compiler error in tree_low_cst, at tree.c:3485
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
etienne@fulbert:~/projet/gujin$
Comment 1 Falk Hueffner 2003-06-16 11:01:44 UTC
Confirmed on 3.4 20030614. Testcase:

char font8x8[256][8] = { [-1] = { 0 } };

test.c:1: internal compiler error: in tree_low_cst, at tree.c:3406

Comment 2 Wolfgang Bangerth 2003-06-16 14:13:32 UTC
It's a regression introduced between 3.0 and 3.2. 2.95 gives this
error:

g/x> gcc -c x.c
x.c:24: duplicate array index in initializer
x.c:24: (near initialization for `font8x8')

Maybe this gives a another clue as to what goes wrong.

W.
Comment 3 Andrew Pinski 2003-06-26 17:33:16 UTC
*** Bug 11333 has been marked as a duplicate of this bug. ***
Comment 4 Mark Mitchell 2003-07-11 23:20:31 UTC
Postponed until GCC 3.3.2.
Comment 5 Andrew Pinski 2003-07-23 19:49:11 UTC
From Phil's regression hunter:
: Search converges between 2002-04-21-trunk (#74) and 2002-04-28-trunk (#75). 
Comment 6 janis187 2003-07-24 21:12:46 UTC
The regression in PR 11207 was introduced or exposed by this patch:

--- gcc/gcc/ChangeLog ---

2002-04-26  Alexandre Oliva  <aoliva@redhat.com>

        * tree.c (tree_int_cst_lt): Compare constants whose types differ
        in unsigned-ness correctly.

The regression hunt used the small test case from comment #1 on
i686-pc-linux-gnu.  Before this patch, compiling that test case gets:

11207.c:1: array index in initializer exceeds array bounds
11207.c:1: (near initialization for `font8x8')
Comment 7 Andrew Pinski 2003-08-10 15:28:18 UTC
A patch was submitted for this: <http://gcc.gnu.org/ml/gcc-patches/2003-08/
msg00606.html>.
Comment 8 Mark Mitchell 2003-08-15 02:02:33 UTC
Subject: Re:  [3.3/3.4 regression] ICE with negative index in
	array element designator

On Sun, 2003-08-10 at 08:28, pinskia at gcc dot gnu dot org wrote:
> PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
> 
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11207
> 
> 
> 
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2003-08-10 15:28 -------
> A patch was submitted for this: <http://gcc.gnu.org/ml/gcc-patches/2003-08/
> msg00606.html>.

That patch is OK for 3.3 and mainline.  Please install!

Comment 9 GCC Commits 2003-08-19 01:36:34 UTC
Subject: Bug 11207

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	kraai@gcc.gnu.org	2003-08-19 01:36:29

Modified files:
	gcc            : ChangeLog c-typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/noncompile: 20030818-1.c 

Log message:
	PR c/11207
	* c-typeck.c (set_init_index): Check for negative index.
	
	(testsuite/)
	* gcc.dg/noncompile/20030818-1.c: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.798&r2=2.799
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&r1=1.252&r2=1.253
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.2975&r2=1.2976
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/noncompile/20030818-1.c.diff?cvsroot=gcc&r1=NONE&r2=1.1

Comment 10 GCC Commits 2003-08-19 01:42:46 UTC
Subject: Bug 11207

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	kraai@gcc.gnu.org	2003-08-19 01:42:37

Modified files:
	gcc            : ChangeLog c-typeck.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg/noncompile: 20030818-1.c 

Log message:
	PR c/11207
	* c-typeck.c (set_init_index): Check for negative index.
	
	(testsuite/)
	
	* gcc.dg/noncompile/20030818-1.c: New.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.708&r2=1.16114.2.709
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/c-typeck.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.213.2.7&r2=1.213.2.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.2261.2.250&r2=1.2261.2.251
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/noncompile/20030818-1.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=NONE&r2=1.1.2.1

Comment 11 Andrew Pinski 2003-08-19 04:52:07 UTC
Fixed by the patch above for 3.3.2 and 3.4.