https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116220
Bug ID: 116220 Summary: -Wmaybe-uninitialised in lto_obj_begin_section Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: lto Assignee: unassigned at gcc dot gnu.org Reporter: sjames at gcc dot gnu.org Target Milestone: --- ``` /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/lto/lto-object.cc: In function ‘lto_obj_begin_section’: /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/lto/lto-object.cc:333:15: warning: ‘err’ may be used uninitialized [-Wmaybe-uninitialized] 333 | if (err == 0) | ^ /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/lto/lto-object.cc:320:7: note: ‘err’ declared here 320 | int err; | ^ /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/lto/lto-object.cc:334:21: warning: ‘errmsg’ may be used uninitialized [-Wmaybe-uninitialized] 334 | fatal_error (input_location, "%s", errmsg); | ^ /var/tmp/portage/sys-devel/gcc-15.0.9999/work/gcc-15.0.9999/gcc/lto/lto-object.cc:319:15: note: ‘errmsg’ declared here 319 | const char *errmsg; | ^ ``` ``` void lto_obj_begin_section (const char *name) { struct lto_simple_object *lo; int align; const char *errmsg; int err; lo = (struct lto_simple_object *) current_out_file; gcc_assert (lo != NULL && lo->sobj_r == NULL && lo->sobj_w != NULL && lo->section == NULL); align = ceil_log2 (POINTER_SIZE_UNITS); lo->section = simple_object_write_create_section (lo->sobj_w, name, align, &errmsg, &err); if (lo->section == NULL) { if (err == 0) fatal_error (input_location, "%s", errmsg); else fatal_error (input_location, "%s: %s", errmsg, xstrerror (errno)); } } ``` so, we use errmsg and assume that simple_object_write_create_section always initialises it if lo->section == NULL. But in libiberty... ``` simple_object_write_section * simple_object_write_create_section (simple_object_write *sobj, const char *name, unsigned int align, const char **errmsg ATTRIBUTE_UNUSED, int *err ATTRIBUTE_UNUSED) { simple_object_write_section *ret; ret = XNEW (simple_object_write_section); ret->next = NULL; ret->name = xstrdup (name); ret->align = align; ret->buffers = NULL; ret->last_buffer = NULL; if (sobj->last_section == NULL) { sobj->sections = ret; sobj->last_section = ret; } else { sobj->last_section->next = ret; sobj->last_section = ret; } return ret; } ``` errmsg is completely untouched and marked as unused, even.