DWARF-5: Initialization due to a false compiler warning [Re: [PATCH v2 4/8] DWARF-5 basic functionality]

Message ID 20170224125741.GA12955@host1.jankratochvil.net
State New, archived
Headers

Commit Message

Jan Kratochvil Feb. 24, 2017, 12:57 p.m. UTC
  Hi,

I finally get the warnings:

dwarf2read.c: In function ‘void create_debug_type_hash_table(dwo_file*, dwarf2_section_info*, htab*&, rcuh_kind)’:
dwarf2read.c:4776:32: error: ‘header.comp_unit_head::type_offset_in_tu.cu_offset::cu_off’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
dwarf2read.c:4816:21: error: ‘header.comp_unit_head::signature’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
cc1plus: all warnings being treated as errors

Even with system gcc-6.3.1-1.fc25.x86_64.  I do not know why I had it
unreproducible before.

OK for check-in?


Jan
gdb/ChangeLog
2017-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* dwarf2read.c (create_debug_type_hash_table): Initialize
	header.signature and header.type_offset_in_tu.
  

Comments

Jan Kratochvil Feb. 26, 2017, 3:56 p.m. UTC | #1
On Fri, 24 Feb 2017 13:57:41 +0100, Jan Kratochvil wrote:
> gdb/ChangeLog
> 2017-02-24  Jan Kratochvil  <jan.kratochvil@redhat.com>
> 
> 	* dwarf2read.c (create_debug_type_hash_table): Initialize
> 	header.signature and header.type_offset_in_tu.

a49dd8dd482da6a8131752f8312a06aa6599063c


Jan
  

Patch

diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index f119750..40b99d9 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -4728,6 +4728,10 @@  create_debug_type_hash_table (struct dwo_file *dwo_file,
 
       offset.sect_off = ptr - section->buffer;
 
+      /* Initialize it due to a false compiler warning.  */
+      header.signature = -1;
+      header.type_offset_in_tu.cu_off = -1;
+
       /* We need to read the type's signature in order to build the hash
 	 table, but we don't need anything else just yet.  */