Patchwork Work-around for a bug in GCC5.

login
register
mail settings
Submitter Joel Brobecker
Date Jan. 29, 2015, 7:38 a.m.
Message ID <20150129073827.GF5193@adacore.com>
Download mbox | patch
Permalink /patch/4842/
State New
Headers show

Comments

Joel Brobecker - Jan. 29, 2015, 7:38 a.m.
Alexander,

On Tue, Jan 27, 2015 at 08:14:39PM +0200, Alexander Klimov wrote:
> Compilation of (GDB) 7.9.50.20150127-cvs with (GCC) 5.0.0 20150127 
> fails with
> 
> In file included from symfile.c:32:0:
> symfile.c: In function 'unmap_overlay_command':
> objfiles.h:628:3: error: 'sec' may be used uninitialized in this 
> function [-Werror=maybe-uninitialized]
>    for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
>    ^
> symfile.c:3442:23: note: 'sec' was declared here
>    struct obj_section *sec;
>                        ^
> cc1: all warnings being treated as errors
> make[2]: *** [symfile.o] Error 1
> make[2]: Leaving directory `gdb/gdb'
> 
> While the bug was reported to GCC as
> <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64823>,
> the attached patch simply initializes sec with NULL.

Thanks for the patch.

In deciding whether to apply this patch, I considered the fact that
GCC 5 is currently unreleased, and so I would probably questioned
the idea of a workaround more if it was more intrusive. But since
this patch is very very simple, I did not see the harm.

So I tested the patch on x86_64 and pushed it. I'm not really sure
whether we might want it for 7.9 or not. I think that'll depend on
the likeliness of GCC being fixed by the time GCC 5 gets released.
If we don't know, I'm not opposed to pushing this one to 7.9 as well.

A few comments, for next time:

  - I didn't check whether you have a copyright assignment on file
    for the GDB project or not. This pach is very small, and therefore
    I applied it under the "tiny patch" rule, where we consider patches
    smaller than 10-15 lines to not be legally significant.

    If you do not have a copyright assignment on file and you are
    thinking of making other contributions to GDB, please contact me
    in private, and I'll send you the form to get started. The process
    takes a few weeks.

  - In terms of submitting the patch, we'd like revision log of
    the commit be a full description of what the commit does,
    what problem it solves, how and why. The nice thing about it
    is that you can usually just "git send-email" it to the list.
    In this particular case, I used the contents of your of your
    email for the revision log.

  - Notice also that I've attached a ChangeLog entry. We require
    ChangeLog entries at time of patch submission, as we often
    use them to see what's changed, and it also allows us to check
    that they are properly formatted and complete.

There are two documents that should be useful for helping you understand
how to help us integrate your patches:
   gdb/CONTRIBUTE
   https://sourceware.org/gdb/wiki/ContributionChecklist

If it looks a bit overwhelming, no worries, we're around to guide
you through them.

gdb/ChangeLog:

        * symfile.c (unmap_overlay_command): Initialize sec to NULL.

Tested on x86_64-linux and pushed to master.
Alexander Klimov - Feb. 17, 2015, 10:17 a.m.
Hi.

On Thu, 29 Jan 2015, Joel Brobecker wrote:
> I'm not really sure whether we might want it for 7.9 or not. I think
> that'll depend on the likeliness of GCC being fixed by the time
> GCC 5 gets released.

The bug was fixed in GCC 5.0.0 20150217, 
the GDB patch is no longer needed.

Patch

From 7a270e0c9ba0eb738a4c30258ab29c09963fcd4d Mon Sep 17 00:00:00 2001
From: Alexander Klimov <alserkli@inbox.ru>
Date: Tue, 27 Jan 2015 19:56:45 +0200
Subject: [PATCH] Fix build failure in symfile.c::unmap_overlay_command (GCC5
 bug)

Compilation of (GDB) 7.9.50.20150127-cvs with (GCC) 5.0.0 20150127
fails with

In file included from symfile.c:32:0:
symfile.c: In function 'unmap_overlay_command':
objfiles.h:628:3: error: 'sec' may be used uninitialized in this
function [-Werror=maybe-uninitialized]
   for (osect = objfile->sections; osect < objfile->sections_end; osect++) \
   ^
symfile.c:3442:23: note: 'sec' was declared here
   struct obj_section *sec;
                       ^
cc1: all warnings being treated as errors
make[2]: *** [symfile.o] Error 1
make[2]: Leaving directory `gdb/gdb'

While the bug was reported to GCC as
<https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64823>,
the attached patch simply initializes sec with NULL.

gdb/ChangeLog:

        * symfile.c (unmap_overlay_command): Initialize sec to NULL.

Tested on x86_64-linux.
---
 gdb/ChangeLog | 4 ++++
 gdb/symfile.c | 2 +-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 03b8712..db4e0b1 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@ 
+2015-01-29  Joel Brobecker  <brobecker@adacore.com>  (tiny patch)
+
+	* symfile.c (unmap_overlay_command): Initialize sec to NULL.
+
 2015-01-27  Doug Evans  <dje@google.com>
 
 	* NEWS: Mention gdb.Objfile.username.
diff --git a/gdb/symfile.c b/gdb/symfile.c
index d55e361..86a758a 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -3439,7 +3439,7 @@  static void
 unmap_overlay_command (char *args, int from_tty)
 {
   struct objfile *objfile;
-  struct obj_section *sec;
+  struct obj_section *sec = NULL;
 
   if (!overlay_debugging)
     error (_("Overlay debugging not enabled.  "
-- 
1.9.1