Fix warning-avoidance initialization in xcoffread.c

With the registry rewrite series, on Fedora 34, I started seeing this
error in xcoffread.c:

../../binutils-gdb/gdb/xcoffread.c: In function ‘void read_xcoff_symtab(objfile*, legacy_psymtab*)’:
../../binutils-gdb/gdb/xcoffread.c:948:25: error: ‘main_aux’ is used uninitialized [-Werror=uninitialized]
  948 |   union internal_auxent fcn_aux_saved = main_aux;
      |                         ^~~~~~~~~~~~~
../../binutils-gdb/gdb/xcoffread.c:933:25: note: ‘main_aux’ declared here
  933 |   union internal_auxent main_aux;
      |                         ^~~~~~~~

I don't know why this error started suddenly... that seems weird,
because it's not obviously related to the changes I made.

Looking into it, it seems this line was intended to avoid a similar
warning -- but since 'main_aux' is uninitialized at the point where it
is used, this fix was incomplete.

This patch avoids the warning by initializing using "{}".  I'm
checking this in.
This commit is contained in:
Tom Tromey 2022-06-05 11:12:57 -06:00
parent cbc30d36ac
commit 2cbde639ae

View File

@ -945,7 +945,7 @@ read_xcoff_symtab (struct objfile *objfile, legacy_psymtab *pst)
struct xcoff_symbol fcn_stab_saved = { 0 };
/* fcn_cs_saved is global because process_xcoff_symbol needs it. */
union internal_auxent fcn_aux_saved = main_aux;
union internal_auxent fcn_aux_saved {};
struct context_stack *newobj;
const char *filestring = pst->filename; /* Name of the current file. */