On Mon, Mar 10, 2008 at 8:24 PM, Jonathan Leffler <
address@hidden> wrote:
I'm not clear whether this is a problem in GCC or in GDB, so I'm asking both teams.
Compiling gdb 6.7.1 on Solaris 10 using the newly installed GCC 4.3.0, I got a compilation error (because of the -Werror option) as shown:
gcc -c -g -O2 -I. -I.././gdb -I.././gdb/config -DLOCALEDIR="\"/usr/gdb/v6.7.1/share/locale\"" -DHAVE_CONFIG_H -I.././gdb/../include/opcode -I.././gdb/../readline/.. -I../bfd -I.././gdb/../bfd -I.././gdb/../include -I./../intl -DMI_OUT=1 -DTUI=1 -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign -Wno-unused -Wno-switch -Wno-char-subscripts -Werror symtab.c
cc1: warnings being treated as errors
symtab.c: In function 'find_line_symtab':
symtab.c:2252: error: 'exact' may be used uninitialized in this function
make: *** [symtab.o] Error 1
The fragment in question was 'worked around' by adding the '= 0' to the declaration of 'exact' at:
struct symtab *
find_line_symtab (struct symtab *symtab, int line, int *index, int *exact_match)
{
int exact = 0;
/* BEST_INDEX and BEST_LINETABLE identify the smallest linenumber > LINE
so far seen. */
int best_index;
struct linetable *best_linetable;
struct symtab *best_symtab;
/* First try looking it up in the given symtab. */
best_linetable = LINETABLE (symtab);
best_symtab = symtab;
best_index = find_line_common (best_linetable, line, &exact);
if (best_index < 0 || !exact)
{
It is not clear to me that GCC is entitled to complain. However, given that it does, the workaround at least allows the compilation to proceed.
[...]