From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D1F3D3839C4E; Wed, 11 May 2022 14:09:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1F3D3839C4E From: "qing.zhao at oracle dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/105539] -ftrivial-auto-var-init=zero happening too late? Date: Wed, 11 May 2022 14:09:17 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 12.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: qing.zhao at oracle dot com X-Bugzilla-Status: UNCONFIRMED 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: 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: Wed, 11 May 2022 14:09:17 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105539 --- Comment #9 from Qing Zhao --- > It's a conditional uninit use which we do not warn on early by design > (for the fear of too many false positives, that is). Okay.=20 >=20 >> 2. the ccp optimization deletes the if (z) statement completely: >>=20 >> [opc@qinzhao-aarch64-ol8 105539]$ cat t.c.034t.ccp1 >>=20 >> ;; Function x (x, funcdef_no=3D0, decl_uid=3D3591, cgraph_uid=3D1, symbo= l_order=3D0) >>=20 >> Removing basic block 3 >> Merging blocks 2 and 4 >> int x (int z) >> { >> int y; >>=20 >> : >> return 10; >>=20 >> } >=20 > That's expected from optimistic lattice propagation which merges TOP with > the constant. If y is initialized to 0 at declaration site, the =E2=80=9Cif z=E2=80=9D st= atement is NOT deleted by CCP.=20 However, per design of -ftrivial-auto-var-init, we intent to not treat y =3D .DEFERRED_INIT (4, 2, &"y"[0]); Same as y=3D 0=20 In order to keep -Wuninitialized warning analysis working as expected. So, yes, I agree that this issue is unavoided based on the current design.= =20 >=20 >> are the above two bugs? >=20 > Well, it works as designed. But sure, that we fail to diagnose the uninit > use is unfortunate and there exist bugs for this specific issue already.=