This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix compile warning in symtab.c
- From: "Christian Biesinger via gdb-patches" <gdb-patches at sourceware dot org>
- To: Tom Tromey <tom at tromey dot com>
- Cc: Christian Biesinger via gdb-patches <gdb-patches at sourceware dot org>
- Date: Sat, 24 Aug 2019 17:47:07 -0400
- Subject: Re: [PATCH] Fix compile warning in symtab.c
- References: <20190822225033.27254-1-cbiesinger@google.com> <87r25bhl0t.fsf@tromey.com>
- Reply-to: Christian Biesinger <cbiesinger at google dot com>
On Fri, Aug 23, 2019 at 1:03 PM Tom Tromey <tom@tromey.com> wrote:
>
> >>>>> "Christian" == Christian Biesinger via gdb-patches <gdb-patches@sourceware.org> writes:
>
> Christian> My compiler (g++ 7.4.0) can't tell that *bsc_ptr and *slot_ptr are
> Christian> only used in the cases when it does get initialized. Just initialize
> Christian> the vars earlier to avoid the warning, there does not seem to be a
> Christian> downside to it.
>
> I think this patch is fine, but I don't understand the connection
> between the patch and the warnings.
GCC can't tell that slot/bsc are only used in the codepath when
symbol_cache_lookup returns "entry not found", so this patch always
initializes them.
> Christian> ../../gdb/symtab.c: In function ‘block_symbol lookup_static_symbol(const char*, domain_enum)’:
> Christian> ../../gdb/symtab.c:1366:11: warning: ‘slot’ may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> It seems to me that if the patch fixes this warning, then it must just
> be a gcc bug?
Yeah, arguably this is a bug that gcc's control flow analysis isn't
smart enough to detect this.
> Anyway, this is ok.
Thanks, pushed.
Christian