* [PATCH] Remove a warning from symtab.c
@ 2019-01-18 14:46 Tom Tromey
2019-01-23 17:02 ` Pedro Alves
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2019-01-18 14:46 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
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-18 Tom Tromey <tom@tromey.com>
* language.h (class scoped_switch_to_sym_language_if_auto):
Initialize m_lang in both cases.
---
gdb/ChangeLog | 5 +++++
gdb/language.h | 7 ++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/gdb/language.h b/gdb/language.h
index 1b880979a8..d56ec20020 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 ()
--
2.17.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Remove a warning from symtab.c
2019-01-18 14:46 [PATCH] Remove a warning from symtab.c Tom Tromey
@ 2019-01-23 17:02 ` Pedro Alves
0 siblings, 0 replies; 2+ messages in thread
From: Pedro Alves @ 2019-01-23 17:02 UTC (permalink / raw)
To: Tom Tromey, gdb-patches
On 01/18/2019 02:46 PM, Tom Tromey wrote:
> 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.
Yeah, seems harmless. OK.
Thanks,
Pedro Alves
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-23 17:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-18 14:46 [PATCH] Remove a warning from symtab.c Tom Tromey
2019-01-23 17:02 ` Pedro Alves
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).