libbacktrace patch committed: Always clear union in read_attribute

Message ID
State New
Headers show

Commit Message

Ian Taylor Nov. 20, 2012, 5:28 p.m. 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.


2012-11-20  Ian Lance Taylor  <>

	* 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: