9516 – Internal error when using a big array (original) (raw)

| 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, }; 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! | | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | |