Don't use class-initialization for the owner union
authorChristian Biesinger <cbiesinger@google.com>
Mon, 18 Nov 2019 01:13:49 +0000 (19:13 -0600)
committerChristian Biesinger <cbiesinger@google.com>
Mon, 18 Nov 2019 17:50:48 +0000 (11:50 -0600)
As reported by PhilippeW, valgrind reports that symtab is uninitialized
when compiling with GCC 4.8.5, which is the default compiler on CentOS 7.

This is apparently a compiler bug fixed in later versions, but to keep
CentOS 7 working, this patch initializes the union explicitly instead of
using a class initializer.

gdb/ChangeLog:

2019-11-18  Christian Biesinger  <cbiesinger@google.com>

* symtab.h (struct symbol) <owner>: Initialize explicitly in the
constructor instead of using a class initializer.

Change-Id: I94f48afeae5d29cf81a280295e2d02e2d7e1c1f1

gdb/ChangeLog
gdb/symtab.h

index 90a2b64d3df2470e71e95033c4b9f0818f0f3c32..0e17d7c39d86b0fe8f6a1ed9d8753e4d18fc9643 100644 (file)
@@ -1,3 +1,8 @@
+2019-11-18  Christian Biesinger  <cbiesinger@google.com>
+
+       * symtab.h (struct symbol) <owner>: Initialize explicitly in the
+       constructor instead of using a class initializer.
+
 2019-11-15  Christian Biesinger  <cbiesinger@google.com>
 
        * Makefile.in: Replace {posix,mingw}-strerror.c with safe-strerror.c.
index a6bd3c44b806fd323b79c5452d3153ac443f96af..1e82182df793d77a0ca7e30385ce5c73a4681d47 100644 (file)
@@ -1113,6 +1113,9 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
       language = language_unknown;
       ada_mangled = 0;
       section = 0;
+      /* GCC 4.8.5 (on CentOS 7) does not correctly compile class-
+         initialization of unions, so we initialize it manually here.  */
+      owner.symtab = nullptr;
     }
 
   /* Data type of value */
@@ -1127,7 +1130,7 @@ struct symbol : public general_symbol_info, public allocate_on_obstack
     /* The symbol table containing this symbol.  This is the file associated
        with LINE.  It can be NULL during symbols read-in but it is never NULL
        during normal operation.  */
-    struct symtab *symtab = nullptr;
+    struct symtab *symtab;
 
     /* For types defined by the architecture.  */
     struct gdbarch *arch;
This page took 0.031721 seconds and 4 git commands to generate.