From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D4C65384402B; Thu, 1 Apr 2021 20:42:41 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D4C65384402B From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/78394] False positives of maybe-uninitialized with -Og Date: Thu, 01 Apr 2021 20:42:41 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 6.1.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_reconfirmed_on cf_known_to_fail cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Apr 2021 20:42:42 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D78394 Martin Sebor 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 --- 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 =E2=80=98float foo()=E2=80=99: pr78394.C:19:17: warning: =E2=80=98vy=E2=80=99 may be used uninitialized in= this function [-Wmaybe-uninitialized] 19 | return vx + vy; | ^~ pr78394.C:13:15: note: used when =E2=80=98(a <=3D i)=E2=80=99 13 | float vx, vy; | ^~ pr78394.C:13:15: note: =E2=80=98vy=E2=80=99 was declared here pr78394.C:19:17: warning: =E2=80=98vx=E2=80=99 may be used uninitialized in= this function [-Wmaybe-uninitialized] 19 | return vx + vy; | ^~ pr78394.C:13:11: note: used when =E2=80=98(a <=3D i)=E2=80=99 13 | float vx, vy; | ^~ pr78394.C:13:11: note: =E2=80=98vx=E2=80=99 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; [local count: 118111600]: # VUSE <.MEM_4(D)> a_5 =3D b; if (a_5 <=3D 3) goto ; [50.00%] else goto ; [50.00%] [local count: 59055800]: goto ; [100.00%] [local count: 59055800]: [local count: 118111600]: # a_1 =3D PHI goto ; [100.00%] [local count: 955630225]: _8 =3D (float) i_2; i_7 =3D i_2 + 1; [local count: 1073741824]: # i_2 =3D PHI <1(4), i_7(5)> # .MEM_3 =3D PHI <.MEM_4(D)(4), .MEM_3(5)> # vx_9 =3D PHI # vy_10 =3D PHI if (a_1 > i_2) goto ; [89.00%] else goto ; [11.00%] [local count: 118111600]: _6 =3D vx_9 + vy_10; # VUSE <.MEM_3> return _6; }=