http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52602
Bug #: 52602 Summary: false compilation warning of uninitialized variable Classification: Unclassified Product: gcc Version: 4.6.3 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c AssignedTo: unassig...@gcc.gnu.org ReportedBy: asmwarr...@gmail.com Hi, when building gdb, I found a false warning, the code is below: static void print_one_vtable (struct gdbarch *gdbarch, struct value *value, int max_voffset, struct value_print_options *opts) { int i; struct type *type = check_typedef (value_type (value)); struct value *vtable; CORE_ADDR vt_addr; vtable = gnuv3_get_vtable (gdbarch, type, value_address (value) + value_embedded_offset (value)); vt_addr = value_address (value_field (vtable, vtable_field_virtual_functions)); printf_filtered (_("vtable for '%s' @ %s (subobject @ %s):\n"), TYPE_SAFE_NAME (type), paddress (gdbarch, vt_addr), paddress (gdbarch, (value_address (value) + value_embedded_offset (value)))); for (i = 0; i <= max_voffset; ++i) { struct value *vfn; CORE_ADDR addr; volatile struct gdb_exception ex; printf_filtered ("[%d]: ", i); vfn = value_subscript (value_field (vtable, vtable_field_virtual_functions), i); if (gdbarch_vtable_function_descriptors (gdbarch)) vfn = value_addr (vfn); TRY_CATCH (ex, RETURN_MASK_ERROR) { addr = value_as_address (vfn); } if (ex.reason < 0) printf_filtered (_("<error: %s>"), ex.message); else print_function_pointer_address (gdbarch, addr, gdb_stdout, opts->addressprint); printf_filtered ("\n"); } } in GDB's source: gnu-v3-abi.c, the warning is: .../../gdb/gdb/gnu-v3-abi.c: In function 'print_one_vtable.isra.2': .../../gdb/gdb/gnu-v3-abi.c:892:33: error: 'addr' may be used uninitialized in this function [-Werror=uninitialized] and the bug is workaround by this patch: http://sourceware.org/ml/gdb-cvs/2012-03/msg00203.html Simply use: CORE_ADDR addr = 0; Yuanhui Zhang