When building with -O2, I've started to see these warnings: ... /data/vries/gdb/src/gdb/ui-out.h:409:18: warning: ‘bkpt_tuple_emitter.ui_out_emit_type<(ui_out_type)0>::m_uiout’ may be used uninitialized in this function [-Wmaybe-uninitialized] /data/vries/gdb/src/gdb/ui-out.h:409:18: warning: ‘outer_tuple_emitter.ui_out_emit_type<(ui_out_type)0>::m_uiout’ may be used uninitialized in this function [-Wmaybe-uninitialized] /data/vries/gdb/src/gdb/ui-out.h:409:18: warning: ‘inner_list_emitter.ui_out_emit_type<(ui_out_type)1>::m_uiout’ may be used uninitialized in this function [-Wmaybe-uninitialized] /data/vries/gdb/src/gdb/ui-out.h:409:18: warning: ‘list_emitter.ui_out_emit_type<(ui_out_type)1>::m_uiout’ may be used uninitialized in this function [-Wmaybe-uninitialized] /data/vries/gdb/src/gdb/ui-out.h:409:18: warning: ‘tuple_emitter.ui_out_emit_type<(ui_out_type)0>::m_uiout’ may be used uninitialized in this function [-Wmaybe-uninitialized] /data/vries/gdb/src/gdb/ui-out.h:409:18: warning: ‘asm_list.ui_out_emit_type<(ui_out_type)1>::m_uiout’ may be used uninitialized in this function [-Wmaybe-uninitialized] /data/vries/gdb/src/gdb/ui-out.h:409:18: warning: ‘output_tuple.ui_out_emit_type<(ui_out_type)0>::m_uiout’ may be used uninitialized in this function [-Wmaybe-uninitialized] /data/vries/gdb/src/gdb/ui-out.h:409:18: warning: ‘sources_list.ui_out_emit_type<(ui_out_type)1>::m_uiout’ may be used uninitialized in this function [-Wmaybe-uninitialized] ...
Bisects to: ... commit 6b09f1342cf2d8e2b13a0d634acc3bcf2852a73b Author: Lancelot Six <lancelot.six@amd.com> Date: Fri Oct 13 09:27:48 2023 +0000 gdb: Replace gdb::optional with std::optional ...
This seems to fix it: ... diff --git a/gdb/ui-out.h b/gdb/ui-out.h index 07567a1df35..0ff9b761102 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -406,14 +405,15 @@ class ui_out_emit_type ~ui_out_emit_type () { - m_uiout->end (Type); + if (m_uiout != nullptr) + m_uiout->end (Type); } DISABLE_COPY_AND_ASSIGN (ui_out_emit_type); private: - struct ui_out *m_uiout; + struct ui_out *m_uiout = nullptr; }; typedef ui_out_emit_type<ui_out_type_tuple> ui_out_emit_tuple; ...
Which compiler is this? I think this was https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635
(In reply to Tom Tromey from comment #3) > Which compiler is this? > I think this was https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80635 That particular PR is fixed in gcc 11.1, and this is with gcc 11.4 on ubuntu 22.04. Anyway, this fixes it as well: ... diff --git a/gdb/ui-out.h b/gdb/ui-out.h index 07567a1df35..ce3bc86b651 100644 --- a/gdb/ui-out.h +++ b/gdb/ui-out.h @@ -406,7 +406,10 @@ class ui_out_emit_type ~ui_out_emit_type () { + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE ("-Wmaybe-uninitialized") m_uiout->end (Type); + DIAGNOSTIC_POP } DISABLE_COPY_AND_ASSIGN (ui_out_emit_type); ...
Maybe another compiler bug report is needed. It would be good to see the full location of the warnings -- the context of the code, not just the immediate spot. It could possibly be a bug there (though I still tend to think it's a compiler problem).
Created attachment 15282 [details] c-reduced symtab.ii $ wc -l symtab.ii 958 symtab.ii
Created attachment 15283 [details] c-reduce script