compile-loc2c: Fix uninitialized variable error
authorSimon Marchi <simon.marchi@ericsson.com>
Sun, 9 Jul 2017 18:25:38 +0000 (20:25 +0200)
committerSimon Marchi <simon.marchi@ericsson.com>
Sun, 9 Jul 2017 18:25:46 +0000 (20:25 +0200)
commit266934d1ad029100f4073f9e351f8685ea175b83
tree0367c66199e024c18f7d1894aa8a2b918aacd27f
parent0327869232a2f447474306a4d88214324d8abd40
compile-loc2c: Fix uninitialized variable error

Compiling with clang gives this warning/error:

  /home/emaisin/src/binutils-gdb/gdb/compile/compile-loc2c.c:731:6: error: variable 'uoffset' is uninitialized when used here [-Werror,-Wuninitialized]
              uoffset += dwarf2_per_cu_text_offset (per_cu);
              ^~~~~~~
  /home/emaisin/src/binutils-gdb/gdb/compile/compile-loc2c.c:669:23: note: initialize the variable 'uoffset' to silence this warning
        uint64_t uoffset, reg;
                        ^
                         = 0

I am really not sure if what this patch does is good, but it is my best
guess.  DW_OP_addr means that there's an constant address provided by
the DWARF bytecode that should be pushed on the stack.  That address is
considered skipped by the "op_ptr += addr_size", but it is never read.
uoffset is indeed read just after, without having been assigned first.

So I think the intent is to read the address, it was just omitted.

gdb/ChangeLog:

* compile/compile-loc2c.c (do_compile_dwarf_expr_to_c): Read
address when op is DW_OP_addr.
gdb/ChangeLog
gdb/compile/compile-loc2c.c
This page took 0.039971 seconds and 4 git commands to generate.