From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 54269 invoked by alias); 18 Nov 2019 17:51:10 -0000 Mailing-List: contact gdb-cvs-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: , Sender: gdb-cvs-owner@sourceware.org List-Subscribe: Sender: gdb-cvs-owner@sourceware.org Received: (qmail 54227 invoked by uid 10256); 18 Nov 2019 17:51:10 -0000 Date: Mon, 18 Nov 2019 17:51:00 -0000 Message-ID: <20191118175110.54225.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Christian Biesinger To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Don't use class-initialization for the owner union X-Act-Checkin: binutils-gdb X-Git-Author: Christian Biesinger X-Git-Refname: refs/heads/master X-Git-Oldrev: ed7e9d0bdaa0cbeb157e427c262e692a993e4432 X-Git-Newrev: 6edc43ec327c2b74e10b80774fa6ecde3dc58537 X-SW-Source: 2019-11/txt/msg00048.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6edc43ec327c2b74e10b80774fa6ecde3dc58537 commit 6edc43ec327c2b74e10b80774fa6ecde3dc58537 Author: Christian Biesinger Date: Sun Nov 17 19:13:49 2019 -0600 Don't use class-initialization for the owner union 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 * symtab.h (struct symbol) : Initialize explicitly in the constructor instead of using a class initializer. Change-Id: I94f48afeae5d29cf81a280295e2d02e2d7e1c1f1 Diff: --- gdb/ChangeLog | 5 +++++ gdb/symtab.h | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 90a2b64..0e17d7c 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2019-11-18 Christian Biesinger + + * symtab.h (struct symbol) : Initialize explicitly in the + constructor instead of using a class initializer. + 2019-11-15 Christian Biesinger * Makefile.in: Replace {posix,mingw}-strerror.c with safe-strerror.c. diff --git a/gdb/symtab.h b/gdb/symtab.h index a6bd3c4..1e82182 100644 --- a/gdb/symtab.h +++ b/gdb/symtab.h @@ -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;