This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix compile warning in symtab.c


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]