public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] gdb/linespec.c: Fix -Wmaybe-uninitialized warning
@ 2023-01-07  0:49 Aaron Merey
  2023-01-09 17:10 ` Tom Tromey
  0 siblings, 1 reply; 4+ messages in thread
From: Aaron Merey @ 2023-01-07  0:49 UTC (permalink / raw)
  To: gdb-patches; +Cc: Aaron Merey

Although the bool want_start_sal isn't actually used without being assigned
a value, initialize it to be false in order to prevent the following
-Wmaybe-uninitialized warning:

    linespec.c: In function ‘void minsym_found(linespec_state*, objfile*, minimal_symbol*, std::vector<symtab_and_line>*)’:
    linespec.c:4150:19: warning: ‘want_start_sal’ may be used uninitialized [-Wmaybe-uninitialized]
     4150 |   if (is_function && want_start_sal)
---
 gdb/linespec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/linespec.c b/gdb/linespec.c
index e9339c3338c..b8c77541a29 100644
--- a/gdb/linespec.c
+++ b/gdb/linespec.c
@@ -4129,7 +4129,7 @@ minsym_found (struct linespec_state *self, struct objfile *objfile,
 	      struct minimal_symbol *msymbol,
 	      std::vector<symtab_and_line> *result)
 {
-  bool want_start_sal;
+  bool want_start_sal = false;
 
   CORE_ADDR func_addr;
   bool is_function = msymbol_is_function (objfile, msymbol, &func_addr);
-- 
2.39.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gdb/linespec.c: Fix -Wmaybe-uninitialized warning
  2023-01-07  0:49 [PATCH] gdb/linespec.c: Fix -Wmaybe-uninitialized warning Aaron Merey
@ 2023-01-09 17:10 ` Tom Tromey
  2023-01-10  1:16   ` Aaron Merey
  0 siblings, 1 reply; 4+ messages in thread
From: Tom Tromey @ 2023-01-09 17:10 UTC (permalink / raw)
  To: Aaron Merey via Gdb-patches; +Cc: Aaron Merey

>>>>> "Aaron" == Aaron Merey via Gdb-patches <gdb-patches@sourceware.org> writes:

Aaron> Although the bool want_start_sal isn't actually used without being assigned
Aaron> a value, initialize it to be false in order to prevent the following
Aaron> -Wmaybe-uninitialized warning:

Thanks, this is ok.
I think normally we allow these little uninitialized warning fixes under
the obvious rule.

Tom

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gdb/linespec.c: Fix -Wmaybe-uninitialized warning
  2023-01-09 17:10 ` Tom Tromey
@ 2023-01-10  1:16   ` Aaron Merey
  2023-01-10  2:53     ` Simon Marchi
  0 siblings, 1 reply; 4+ messages in thread
From: Aaron Merey @ 2023-01-10  1:16 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Aaron Merey via Gdb-patches

Hi Tom,

On Mon, Jan 9, 2023 at 12:10 PM Tom Tromey <tom@tromey.com> wrote:
> Thanks, this is ok.
> I think normally we allow these little uninitialized warning fixes under
> the obvious rule.

Thanks, pushed as commit 2ff63a29b0b. Will push as obvious next time.

Aaron


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gdb/linespec.c: Fix -Wmaybe-uninitialized warning
  2023-01-10  1:16   ` Aaron Merey
@ 2023-01-10  2:53     ` Simon Marchi
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Marchi @ 2023-01-10  2:53 UTC (permalink / raw)
  To: Aaron Merey, Tom Tromey; +Cc: Aaron Merey via Gdb-patches



On 1/9/23 20:16, Aaron Merey via Gdb-patches wrote:
> Hi Tom,
> 
> On Mon, Jan 9, 2023 at 12:10 PM Tom Tromey <tom@tromey.com> wrote:
>> Thanks, this is ok.
>> I think normally we allow these little uninitialized warning fixes under
>> the obvious rule.
> 
> Thanks, pushed as commit 2ff63a29b0b. Will push as obvious next time.
> 
> Aaron
> 

In my opinion, these shouldn't be obvious, because there's always the
chance that the compiler is actually right (and the author misses it),
and by initializing the variable, we cover up a bug.

Simon

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-01-10  2:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-07  0:49 [PATCH] gdb/linespec.c: Fix -Wmaybe-uninitialized warning Aaron Merey
2023-01-09 17:10 ` Tom Tromey
2023-01-10  1:16   ` Aaron Merey
2023-01-10  2:53     ` Simon Marchi

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).