This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch to expand_builtin_stpcpy to copy `arglist' before modifying


As suggested by Roger here:
http://gcc.gnu.org/ml/gcc-patches/2003-05/msg00155.html

I've updated expand_builtin_stpcpy to copy `arglist' before modifying
it.  The patch has no effect on the PR we've been discussing, but this
is still more correct.

Tested by compiling cc1 and running the stpcpy testcase
string-opt-18.c on sparc-sun-solaris2.7.  Full bootstrap and testsuite
underway.  Assuming that completes, ok for mainline?

		Thanks,
		--Kaveh


2003-05-02  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* builtins.c (expand_builtin_stpcpy): Copy `arglist' before
	modifying it.

diff -rup orig/egcc-CVS20030501/gcc/builtins.c egcc-CVS20030501/gcc/builtins.c
--- orig/egcc-CVS20030501/gcc/builtins.c	2003-04-28 10:00:20.000000000 -0400
+++ egcc-CVS20030501/gcc/builtins.c	2003-05-02 10:16:54.981463314 -0400
@@ -2491,13 +2491,15 @@ expand_builtin_stpcpy (arglist, target, 
     return 0;
   else
     {
+      tree newarglist;
       tree len = c_strlen (TREE_VALUE (TREE_CHAIN (arglist)));
       if (len == 0)
 	return 0;
 
       len = fold (size_binop (PLUS_EXPR, len, ssize_int (1)));
-      chainon (arglist, build_tree_list (NULL_TREE, len));
-      return expand_builtin_memcpy (arglist, target, mode, /*endp=*/2);
+      newarglist = copy_list (arglist);
+      chainon (newarglist, build_tree_list (NULL_TREE, len));
+      return expand_builtin_memcpy (newarglist, target, mode, /*endp=*/2);
     }
 }
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]