PATCH: Fix PR 9516
Christian Ehrhardt
ehrhardt@mathematik.uni-ulm.de
Sat Apr 5 09:38:00 GMT 2003
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9516
This PR is a stack overfow when initializing a very large array.
The problem is that the initializer is a TREE_LIST that is passed
to safe_from_p which handles TREE_LISTs recursivly. With the testcase
in the PR this is deadly if the stack size limit is around 50 Megabytes.
This patch removes the recursion. Bootstrapped and regtested on x86.
Can someone please commit this?
regards Christian
PR c/9516
* expr.c (safe_from_p): Don't recurse on TREE_LISTs.
Index: expr.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/expr.c,v
retrieving revision 1.517
diff -u -r1.517 expr.c
--- expr.c 1 Apr 2003 13:40:07 -0000 1.517
+++ expr.c 5 Apr 2003 09:11:29 -0000
@@ -6093,10 +6093,13 @@
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)));
+ {
+ tree tmp;
+ for (tmp = exp; tmp; tmp = TREE_CHAIN (tmp))
+ if (TREE_VALUE (tmp) && safe_from_p (x, TREE_VALUE (tmp), 0))
+ return 0;
+ return 1;
+ }
else if (TREE_CODE (exp) == ERROR_MARK)
return 1; /* An already-visited SAVE_EXPR? */
else
--
THAT'S ALL FOLKS!
More information about the Gcc-patches
mailing list