https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78394
Martin Sebor <msebor at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Last reconfirmed|2017-07-20 00:00:00 |2021-4-1 Known to fail| |10.2.0, 11.0, 6.3.0, 7.0.1, | |8.3.0, 9.3.0 CC| |msebor at gcc dot gnu.org --- Comment #16 from Martin Sebor <msebor at gcc dot gnu.org> --- Reconfirming with GCC 11. Both instances of the warning go back as far as support for -Og so it's not a regression. With my patched GCC the output for just the first function is: pr78394.C: In function ‘float foo()’: pr78394.C:19:17: warning: ‘vy’ may be used uninitialized in this function [-Wmaybe-uninitialized] 19 | return vx + vy; | ^~ pr78394.C:13:15: note: used when ‘(a <= i)’ 13 | float vx, vy; | ^~ pr78394.C:13:15: note: ‘vy’ was declared here pr78394.C:19:17: warning: ‘vx’ may be used uninitialized in this function [-Wmaybe-uninitialized] 19 | return vx + vy; | ^~ pr78394.C:13:11: note: used when ‘(a <= i)’ 13 | float vx, vy; | ^~ pr78394.C:13:11: note: ‘vx’ was declared here The dump the warning sees is below as as noted the root cause is that the IL satisfies the conditions under which it's designed to trigger. So the only ways to avoid it would seem to be to either a) extend the warning to figure out that the condition it uses cannot happen (basically implement some of the optimizations disabled at -Og) or b) turn off -Wmaybe-uninitialized at -Og (i.e,. remove it from -Wall). I'm not in favor of (a) but (b) makes sense to me. I'd like to try to improve it for GCC 12 so unless I fail at that I'm not for disabling it at other optimization levels. float foo () { int i; float vy; float vx; int a; float _6; float _8; <bb 2> [local count: 118111600]: # VUSE <.MEM_4(D)> a_5 = b; if (a_5 <= 3) goto <bb 3>; [50.00%] else goto <bb 8>; [50.00%] <bb 8> [local count: 59055800]: goto <bb 4>; [100.00%] <bb 3> [local count: 59055800]: <bb 4> [local count: 118111600]: # a_1 = PHI <a_5(8), 4(3)> goto <bb 6>; [100.00%] <bb 5> [local count: 955630225]: _8 = (float) i_2; i_7 = i_2 + 1; <bb 6> [local count: 1073741824]: # i_2 = PHI <1(4), i_7(5)> # .MEM_3 = PHI <.MEM_4(D)(4), .MEM_3(5)> # vx_9 = PHI <vx_11(D)(4), _8(5)> # vy_10 = PHI <vy_12(D)(4), _8(5)> if (a_1 > i_2) goto <bb 5>; [89.00%] else goto <bb 7>; [11.00%] <bb 7> [local count: 118111600]: _6 = vx_9 + vy_10; # VUSE <.MEM_3> return _6; }