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] initialize sparse sets with xcalloc


For mainline cc1 with the testcase in PR33635 with -O1, valgrind reports
use of uninitialized values in global_conflices at sparseset.h:90.
I don't have a test case where it makes a difference, but this patch
stops the complaint from valgrind.  Tested on powerpc64-linux, ok for
mainline?  (It's quite possible there's a better fix for this.)

2007-10-30  Janis Johnson  <janis187@us.ibm.com

	* sparseset.c (sparseset_alloc): Use xcalloc rather than xmalloc.

Index: gcc/sparseset.c
===================================================================
--- gcc/sparseset.c	(revision 129723)
+++ gcc/sparseset.c	(working copy)
@@ -30,7 +30,7 @@
   unsigned int n_bytes = sizeof (struct sparseset_def)
 			 + ((n_elms - 1) * 2 * sizeof (SPARSESET_ELT_TYPE));
 
-  sparseset set = (sparseset) xmalloc (n_bytes);
+  sparseset set = (sparseset) xcalloc (1, n_bytes);
   set->dense = &(set->elms[0]);
   set->sparse = &(set->elms[n_elms]);
   set->size = n_elms;



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