http://gcc.gnu.org/ml/gcc-regression/2012-11/msg00279.html points out a
may-be-used-uninitialized warning, turned into an error, when building
libbacktrace.  The warning is incorrect: the value is initialized.  The
warning will no longer turn into an error.  But it is easy enough to
force an initialization to avoid the warning.  That is what this patch
does.  Bootstrapped and ran libbacktrace testsuite on
x86_64-unknown-linux-gnu.  Committed to mainline.

Ian


2012-11-20  Ian Lance Taylor  <i...@google.com>

        * dwarf.c (read_attribute): Always clear val.


Index: dwarf.c
===================================================================
--- dwarf.c	(revision 193484)
+++ dwarf.c	(working copy)
@@ -654,6 +654,12 @@ read_attribute (enum dwarf_form form, st
 		const unsigned char *dwarf_str, size_t dwarf_str_size,
 		struct attr_val *val)
 {
+  /* Avoid warnings about val.u.FIELD may be used uninitialized if
+     this function is inlined.  The warnings aren't valid but can
+     occur because the different fields are set and used
+     conditionally.  */
+  memset (val, 0, sizeof *val);
+
   switch (form)
     {
     case DW_FORM_addr:

Reply via email to