This is the mail archive of the gdb-cvs@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]

[binutils-gdb] Remove a warning from symtab.c


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ae73e2e2435cb706b18ba05734aee4137a271b3c

commit ae73e2e2435cb706b18ba05734aee4137a271b3c
Author: Tom Tromey <tom@tromey.com>
Date:   Fri Jan 18 07:45:01 2019 -0700

    Remove a warning from symtab.c
    
    When building symtab.c, I get:
    
    ../../binutils-gdb/gdb/language.h: In function â??void print_symbol_info(search_domain, symbol*, int, const char*)â??:
    ../../binutils-gdb/gdb/language.h:738:20: warning: â??*((void*)& l +4)â?? may be used uninitialized in this function [-Wmaybe-uninitialized]
           set_language (m_lang);
           ~~~~~~~~~~~~~^~~~~~~~
    ../../binutils-gdb/gdb/symtab.c:4613:41: note: â??*((void*)& l +4)â?? was declared here
       scoped_switch_to_sym_language_if_auto l (sym);
                                             ^
    
    This is another instance of the std::optional problem, see
    https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635.
    
    However, it seemed straightforward and inexpensive to me to silence
    this one, which is what this patch does.
    
    gdb/ChangeLog
    2019-01-23  Tom Tromey  <tom@tromey.com>
    
    	* language.h (class scoped_switch_to_sym_language_if_auto):
    	Initialize m_lang in both cases.

Diff:
---
 gdb/ChangeLog  | 5 +++++
 gdb/language.h | 7 ++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index f342acd..f302fc4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-23  Tom Tromey  <tom@tromey.com>
+
+	* language.h (class scoped_switch_to_sym_language_if_auto):
+	Initialize m_lang in both cases.
+
 2019-01-23  Alan Hayward  <alan.hayward@arm.com>
 
 	* nat/aarch64-linux.c (aarch64_linux_new_thread): Replace XNEW
diff --git a/gdb/language.h b/gdb/language.h
index 1b88097..d56ec20 100644
--- a/gdb/language.h
+++ b/gdb/language.h
@@ -726,7 +726,12 @@ public:
 	set_language (SYMBOL_LANGUAGE (sym));
       }
     else
-      m_switched = false;
+      {
+	m_switched = false;
+	/* Assign to m_lang to silence a GCC warning.  See
+	   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635.  */
+	m_lang = language_unknown;
+      }
   }
 
   ~scoped_switch_to_sym_language_if_auto ()


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