From patchwork Mon Nov 18 01:16:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Simon Marchi (Code Review)" X-Patchwork-Id: 36002 Received: (qmail 74672 invoked by alias); 18 Nov 2019 01:16:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 74664 invoked by uid 89); 18 Nov 2019 01:16:22 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3 autolearn=ham version=3.3.1 spammy= X-HELO: mx1.osci.io Received: from polly.osci.io (HELO mx1.osci.io) (8.43.85.229) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 18 Nov 2019 01:16:20 +0000 Received: by mx1.osci.io (Postfix, from userid 994) id E8C18200EF; Sun, 17 Nov 2019 20:16:18 -0500 (EST) Received: from gnutoolchain-gerrit.osci.io (gnutoolchain-gerrit.osci.io [IPv6:2620:52:3:1:5054:ff:fe06:16ca]) by mx1.osci.io (Postfix) with ESMTP id C433D20300; Sun, 17 Nov 2019 20:16:17 -0500 (EST) Received: from localhost (localhost [127.0.0.1]) by gnutoolchain-gerrit.osci.io (Postfix) with ESMTP id 84B182816F; Sun, 17 Nov 2019 20:16:17 -0500 (EST) X-Gerrit-PatchSet: 1 Date: Sun, 17 Nov 2019 20:16:17 -0500 From: "Christian Biesinger (Code Review)" To: gdb-patches@sourceware.org Cc: Christian Biesinger Message-ID: Auto-Submitted: auto-generated X-Gerrit-MessageType: newchange Subject: [review] Don't use class-initialization for the owner union X-Gerrit-Change-Id: I94f48afeae5d29cf81a280295e2d02e2d7e1c1f1 X-Gerrit-Change-Number: 684 X-Gerrit-ChangeURL: X-Gerrit-Commit: 7cced7a8551025b114dd5ce427f0f74e10821b8e References: Reply-To: cbiesinger@google.com, cbiesinger@google.com, gdb-patches@sourceware.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Gerrit/3.0.3-79-g83ff7f88f1 Change URL: https://gnutoolchain-gerrit.osci.io/r/c/binutils-gdb/+/684 ...................................................................... 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-17 Christian Biesinger * symtab.h (struct symbol) : Initialize explicitly in the constructor instead of using a class initializer. Change-Id: I94f48afeae5d29cf81a280295e2d02e2d7e1c1f1 --- M gdb/symtab.h 1 file changed, 4 insertions(+), 1 deletion(-) 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 @@ 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 @@ /* 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;