[committed] Fix genemit segfault

Michael Matz matz@suse.de
Mon Nov 13 14:37:00 GMT 2006


Hi,

genemit segfault for me and valgrind points to the source of the problem, 
this fixes it.  Committed as obvious (in case it isn't: the used[] array 
will be subscribed by the actual operand number where scratch and dup 
operands also count, but the 'operands' variable only holds the number 
without scratches or dups).


Ciao,
Michael.

	* genemit.c (gen_expand): Allocate enough memory.

Index: genemit.c
===================================================================
--- genemit.c	(revision 118760)
+++ genemit.c	(working copy)
@@ -534,7 +534,8 @@ gen_expand (rtx expand)
      Use emit_insn to add them to the sequence being accumulated.
      But don't do this if the user's code has set `no_more' nonzero.  */
 
-  used = XCNEWVEC (char, operands);
+  used = XCNEWVEC (char,
+		   MAX (operands, MAX (max_scratch_opno, max_dup_opno) + 1));
 
   for (i = 0; i < XVECLEN (expand, 1); i++)
     {



More information about the Gcc-patches mailing list