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 fix recent cp-demangle.c change


The recent change made to libiberty/cp-demangle.c broke bootstraps
with stage1 compilers that don't have dynamic arrays, e.g. on solaris2
with cc I get:

 > cc -c -DHAVE_CONFIG_H -g -I.
 >    -I../../egcc-CVS20031224/libiberty/../include
 >    ../../egcc-CVS20031224/libiberty/cp-demangle.c -o cp-demangle.o
 > "cp-demangle.c", line 4088: undefined symbol: palc
 > cc: acomp failed for cp-demangle.c
 > make[1]: *** [cp-demangle.o] Error 2

The fix is simple.  However it begs the question, why do we have two
code paths to do the same thing?  I'm guessing the non-c99/non-gcc
case wasn't tested which lead to the problem.

I'm all for speedups.  But why not instead use alloca, and let
libiberty.h decide (under the hood) whether your alloca puts things on
the stack or uses malloc?  (Can I assume gcc's alloca is the same
speed-wise as a dynamic array?)  Doing that would simplify the code in
cp-demangle.c and avoid the problem of not testing both code paths.
Anyway, 'nuff said.

Patch tested on sparc-sun-solaris2.7.  Ok for mainline?

		Thanks,
		--Kaveh


2003-12-24  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* cp-demangle.c (is_ctor_or_dtor): Fix error in last change.
	
diff -rup orig/egcc-CVS20031224/libiberty/cp-demangle.c egcc-CVS20031224/libiberty/cp-demangle.c
--- orig/egcc-CVS20031224/libiberty/cp-demangle.c	2003-12-22 20:02:12.000000000 -0500
+++ egcc-CVS20031224/libiberty/cp-demangle.c	2003-12-24 20:45:57.942422000 -0500
@@ -4085,7 +4085,6 @@ is_ctor_or_dtor (mangled, ctor_kind, dto
 	  free (di.comps);
 	if (di.subs != NULL)
 	  free (di.subs);
-	*palc = 1;
 	return NULL;
       }
 #endif


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