https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116222
Bug ID: 116222 Summary: -Wmaybe-uninitialized in record_target_from_binfo in ipa-devirt.cc Product: gcc Version: 15.0 Status: UNCONFIRMED Keywords: build Severity: normal Priority: P3 Component: ipa Assignee: unassigned at gcc dot gnu.org Reporter: sjames at gcc dot gnu.org Blocks: 24639, 44756 Target Milestone: --- During an LTO bootstrap, I saw: ``` /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/ipa-devirt.cc:2590:31: warning: ‘can_refer’ may be used uninitialized [-Wmaybe-uninitialized] 2590 | maybe_record_node (nodes, target, inserted, can_refer, completep); | ^ /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/ipa-devirt.cc:2585:16: note: ‘can_refer’ declared here 2585 | bool can_refer; | ^ ``` We have in ipa-devirt.cc: ``` static void record_target_from_binfo (vec <cgraph_node *> &nodes, [...] bool can_refer; tree target = gimple_get_virt_method_for_binfo (otr_token, inner_binfo, &can_refer); if (!bases_to_consider) maybe_record_node (nodes, target, inserted, can_refer, completep); /* Destructors are never called via construction vtables. */ else if (!target || !DECL_CXX_DESTRUCTOR_P (target)) bases_to_consider->safe_push (target); [...] ``` But in gimple-fold.cc: ``` tree gimple_get_virt_method_for_binfo (HOST_WIDE_INT token, tree known_binfo, bool *can_refer) { unsigned HOST_WIDE_INT offset; tree v; v = BINFO_VTABLE (known_binfo); /* If there is no virtual methods table, leave the OBJ_TYPE_REF alone. */ if (!v) return NULL_TREE; if (!vtable_pointer_value_to_vtable (v, &v, &offset)) { if (can_refer) *can_refer = false; return NULL_TREE; } return gimple_get_virt_method_for_vtable (token, v, offset, can_refer); } ``` We don't always initialise can_refer there. Referenced Bugs: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=24639 [Bug 24639] [meta-bug] bug to track all Wuninitialized issues https://gcc.gnu.org/bugzilla/show_bug.cgi?id=44756 [Bug 44756] [meta-bug] --enable-werror-always issues