From patchwork Fri Mar 27 13:42:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Joel Brobecker X-Patchwork-Id: 5846 Received: (qmail 93306 invoked by alias); 27 Mar 2015 13:42:56 -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 93291 invoked by uid 89); 27 Mar 2015 13:42:55 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.8 required=5.0 tests=AWL, BAYES_00, LIKELY_SPAM_BODY autolearn=no version=3.3.2 X-HELO: rock.gnat.com Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Fri, 27 Mar 2015 13:42:54 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id A64EB11656A; Fri, 27 Mar 2015 09:42:52 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 4FpDy1pIs65A; Fri, 27 Mar 2015 09:42:52 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 7ECF6116569; Fri, 27 Mar 2015 09:42:52 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 424B740EAD; Fri, 27 Mar 2015 06:42:52 -0700 (PDT) Date: Fri, 27 Mar 2015 06:42:52 -0700 From: Joel Brobecker To: Tobias Burnus Cc: gdb-patches@sourceware.org Subject: Re: gdb fails to compile with GCC 4.4.7 (was: [PATCH V4 5/9] New probe type: DTrace USDT probes.) Message-ID: <20150327134252.GD13867@adacore.com> References: <20150326210014.GC13867@adacore.com> <20150327094653.GA29713@physik.fu-berlin.de> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150327094653.GA29713@physik.fu-berlin.de> User-Agent: Mutt/1.5.21 (2010-09-15) > I think this patch (commit 429e1e811b400f07b5a514ea6b8a70b28e2d7ee9) causes > gdb's compilation to fail with GCC 4.4.7 (RHEL 6 system compiler) as follows; > it does work with GCC 5. > > cc1: warnings being treated as errors > ../../gdb/dtrace-probe.c: In function ‘dtrace_process_dof_probe’: > ../../gdb/dtrace-probe.c:416: error: ‘expr’ may be used uninitialized in this function > make[2]: *** [dtrace-probe.o] Error 1 > > > I think that looks spurious as the code looks fine (i.e. GCC is overzaelous), still, > a "= NULL" should harm. Would you mind checking that the attached patch fixes the problem? gdb/ChangeLog: * dtrace-probe.c (dtrace_process_dof_probe): Initialize expr to NULL. Tested on x86_64-linux by rebuilding GDB. Thank you, From 9b1d494cfb04c4d05252af84545f060bd67bcb87 Mon Sep 17 00:00:00 2001 From: Joel Brobecker Date: Fri, 27 Mar 2015 06:37:34 -0700 Subject: [PATCH] Initialize EXPR in dtrace-probe::dtrace_process_dof_probe MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 4.4.7 generates the following warning: | cc1: warnings being treated as errors | dtrace-probe.c: In function ‘dtrace_process_dof_probe’: | dtrace-probe.c:416: error: ‘expr’ may be used uninitialized in this function | make[2]: *** [dtrace-probe.o] Error 1 Later versions (GCC 5) do a better job and don't generate the warning, but it does not hurt to pre-initialize "expr" to NULL. gdb/ChangeLog: * dtrace-probe.c (dtrace_process_dof_probe): Initialize expr to NULL. --- gdb/dtrace-probe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gdb/dtrace-probe.c b/gdb/dtrace-probe.c index ff7ce7d..3f2548d 100644 --- a/gdb/dtrace-probe.c +++ b/gdb/dtrace-probe.c @@ -413,7 +413,7 @@ dtrace_process_dof_probe (struct objfile *objfile, for (j = 0; j < ret->probe_argc; j++) { struct dtrace_probe_arg arg; - struct expression *expr; + struct expression *expr = NULL; /* Set arg.expr to ensure all fields in expr are initialized and the compiler will not warn when arg is used. */ -- 1.9.1