Remove a warning from symtab.c
authorTom Tromey <tom@tromey.com>
Fri, 18 Jan 2019 14:45:01 +0000 (07:45 -0700)
committerTom Tromey <tom@tromey.com>
Wed, 23 Jan 2019 17:34:55 +0000 (10:34 -0700)
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.

gdb/ChangeLog
gdb/language.h

index f342acd8fb81412ba861c9ab887babee565f8398..f302fc4a82ebb27bc362dcc26c8d21a4e6505caa 100644 (file)
@@ -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
index 1b880979a8ea12006a483e67b986533e322c8561..d56ec2002086b4ce833130ab550e7b2b1cd8cba4 100644 (file)
@@ -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 ()