Bug 9516 - Internal error when using a big array
Summary: Internal error when using a big array
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 3.2.2
: P2 critical
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: ice-on-valid-code
Depends on:
Blocks:
 
Reported: 2003-01-30 21:46 UTC by p.allix
Modified: 2003-07-25 17:33 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-02-01 00:00:00


Attachments
bug.tar.gz (2.29 MB, application/x-gzip )
2003-05-21 15:17 UTC, p.allix
Details

Note You need to log in before you can comment on or make changes to this bug.
Description p.allix 2003-01-30 21:46:00 UTC
Using a very very big array in C source will cause gcc to have an internal error.

Release:
3.2.2

Environment:
Linux debian 2.4.18-bf2.4  i686  GNU/Linux

How-To-Repeat:
gcc usetab.c
Comment 1 p.allix 2003-01-30 21:46:00 UTC
Fix:
Using many array instead of a big one :(
Comment 2 Wolfgang Bangerth 2003-02-01 22:14:42 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Ugh, really large array...
    
    I still get the error with a snapshot from yesterday.
    W.
Comment 3 Christian Ehrhardt 2003-04-04 19:48:41 UTC
From: "Christian Ehrhardt" <ehrhardt@mathematik.uni-ulm.de>
To: gcc-gnats@gcc.gnu.org, p.allix@ifrance.com, gcc-bugs@gcc.gnu.org,
  nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org
Cc:  
Subject: Re: c/9516: [2003-02-01] Internal error when using a big array
Date: Fri, 4 Apr 2003 19:48:41 +0200

 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9516
 
 Hi,
 
 this PR is about a segfault when initializing an array like this:
 
 unsigned char tab[] = { 1,2,3,4,<several million initializer element> };
 
 The reason is a stack overflow because the initializer elements are
 in a TREE_LIST and this list is passed to expr.c:safe_from_p which
 does an infinite recursion in this piece of code:
 
     case 'x':
       if (TREE_CODE (exp) == TREE_LIST)
         return ((TREE_VALUE (exp) == 0
                  || safe_from_p (x, TREE_VALUE (exp), 0))
                 && (TREE_CHAIN (exp) == 0
                     || safe_from_p (x, TREE_CHAIN (exp), 0)));
 
 I guess that rewriting this as:
     case 'x':
       if (TREE_CODE (exp) == TREE_LIST)
 	{
 	  tree tmp;
 	  for (tmp = exp; tmp; tmp = TREE_CHAIN(tmp))
 	    {
 	      if (TREE_VALUE(exp) != 0 && !safe_from_p (x, TREE_VALUE (tmp), 0))
 		return 0;
 	    }
 	  return 1;
 	}
 
 should fix this PR. I'll bootstrap and regtest.
 
    regards  Christian
 
 -- 
 THAT'S ALL FOLKS!

Comment 4 Richard Henderson 2003-04-08 00:22:39 UTC
From: rth@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c/9516
Date: 8 Apr 2003 00:22:39 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Branch: 	gcc-3_3-branch
 Changes by:	rth@gcc.gnu.org	2003-04-08 00:22:39
 
 Modified files:
 	gcc            : ChangeLog expr.c 
 
 Log message:
 	PR c/9516
 	* expr.c (safe_from_p): Rearrange to avoid deep recursion in
 	favour of looping and tail recursion for TREE_LIST and binops.
 
 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.416&r2=1.16114.2.417
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/expr.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.498.2.12&r2=1.498.2.13
 

Comment 5 Richard Henderson 2003-04-08 00:23:17 UTC
From: rth@gcc.gnu.org
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c/9516
Date: 8 Apr 2003 00:23:17 -0000

 CVSROOT:	/cvs/gcc
 Module name:	gcc
 Changes by:	rth@gcc.gnu.org	2003-04-08 00:23:17
 
 Modified files:
 	gcc            : ChangeLog expr.c 
 
 Log message:
 	PR c/9516
 	* expr.c (safe_from_p): Rearrange to avoid deep recursion in
 	favour of looping and tail recursion for TREE_LIST and binops.
 
 Patches:
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=1.17360&r2=1.17361
 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/expr.c.diff?cvsroot=gcc&r1=1.517&r2=1.518
 
Comment 6 Richard Henderson 2003-04-09 04:48:50 UTC
State-Changed-From-To: analyzed->closed
State-Changed-Why: http://gcc.gnu.org/ml/gcc-patches/2003-04/msg00501.html