https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90844
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |msebor at gcc dot gnu.org Summary|Another case of missing use |missing |of uninitialized variable |-Wmaybe-uninitialized with |warning (inlining, CCP) |-flto and optimization Last reconfirmed|2019-06-12 00:00:00 |2021-4-15 Known to fail| |10.2.0, 11.0, 8.3.0, 9.3.0 --- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> --- The late uninit pass doesn't run with -flto; all that runs is the early uninitialized pass and it disables the "conditional" -Wmaybe-uninitialized when optimization is enabled: static unsigned int execute_early_warn_uninitialized (void) { /* Currently, this pass runs always but execute_late_warn_uninitialized only runs with optimization. With optimization we want to warn about possible uninitialized as late as possible, thus don't do it here. However, without optimization we need to warn here about "may be uninitialized". */ calculate_dominance_info (CDI_POST_DOMINATORS); warn_uninitialized_vars (/*warn_maybe_uninitialized=*/!optimize); ^^^^^^^^^ Changing that like so lets the warning do its thing even with -flto: @@ -3086,7 +3079,8 @@ execute_early_warn_uninitialized (void) optimization we need to warn here about "may be uninitialized". */ calculate_dominance_info (CDI_POST_DOMINATORS); - warn_uninitialized_vars (/*warn_maybe_uninitialized=*/!optimize); + bool wmaybe_uninit = !optimize || flag_lto; + warn_uninitialized_vars (wmaybe_uninit); /* Post-dominator information cannot be reliably updated. Free it after the use. */