This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] initialize sparse sets with xcalloc
- From: Janis Johnson <janis187 at us dot ibm dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Tue, 30 Oct 2007 15:19:26 -0700
- Subject: [PATCH] initialize sparse sets with xcalloc
- Reply-to: janis187 at us dot ibm dot com
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;