[PATCH] Fix compile warning in symtab.c
Christian Biesinger via gdb-patches
Sat Aug 24 21:47:00 GMT 2019
On Fri, Aug 23, 2019 at 1:03 PM Tom Tromey <email@example.com> wrote:
> >>>>> "Christian" == Christian Biesinger via gdb-patches <firstname.lastname@example.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
> 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.
More information about the Gdb-patches