This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: gdb fails to compile with GCC 4.4.7 (was: [PATCH V4 5/9] New probe type: DTrace USDT probes.)


> 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,
-- 
Joel
>From 9b1d494cfb04c4d05252af84545f060bd67bcb87 Mon Sep 17 00:00:00 2001
From: Joel Brobecker <brobecker@adacore.com>
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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]