From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 0B1E8385843A; Tue, 28 Feb 2023 17:11:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B1E8385843A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1677604294; bh=TMO6g4zEzMg3DgT3acEvr/N40EnycUTD08DjFQI7000=; h=From:To:Subject:Date:In-Reply-To:References:From; b=GFYc06ZCPXEd+Sv/aJqobKUjo689PdXNoVdhe47Nae4RDsONRcgQ0WrtznJh0IHJo Me4uez/55qT9UM4mKsgyIIfaZzUaGqv2d64b38wwhG4njrBKlExAtP7tw2Yv6ZPBwW RnlhCfJf4EbkIlb5oD1ClAf+hklU0sEDKury/QhM= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/107411] trivial-auto-var-init=zero invalid uninitialized variable warning Date: Tue, 28 Feb 2023 17:11:31 +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: 13.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: qinzhao 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D107411 --- Comment #14 from CVS Commits --- The master branch has been updated by Qing Zhao : https://gcc.gnu.org/g:afe6cea4489846aa8585f3c045d16cdaa08cc6cd commit r13-6379-gafe6cea4489846aa8585f3c045d16cdaa08cc6cd Author: Qing Zhao Date: Tue Feb 28 17:11:05 2023 +0000 Fixing PR107411 This is a bug in tree-ssa-uninit.cc. When doing the following: /* Ignore the call to .DEFERRED_INIT that define the original var itself as the following case: temp =3D .DEFERRED_INIT (4, 2, =C3=A2alt_reloc"); alt_reloc =3D temp; In order to avoid generating warning for the fake usage at alt_reloc =3D temp. */ We need to compare the var name inside the .DEFERRED_INIT call (the 3rd argument) and the name for the LHS variable. if they are the s= ame, we will NOT report the warning. There is one issue when we get the name for the LHS variable. when the variable doesn't have a DECL_NAME (it's not a user declared variable, which is the case for this bug): _1 =3D .DEFERRED_INIT (4, 2, &"D.2389"[0]); D.2389 =3D _1; The current checking just ignores this case, and still report the warni= ng. The fix is very simple, when getting the name for the LHS variable, we should consider this case and come up with the name the same way as we constru= ct the 3rd argument for the call to .DEFERRED_INIT (please refer to the routine "gimple_add_init_for_auto_var") PR middle-end/107411 gcc/ChangeLog: PR middle-end/107411 * gimplify.cc (gimple_add_init_for_auto_var): Use sprintf to replace xasprintf. * tree-ssa-uninit.cc (warn_uninit): Handle the case when the LHS varaible of a .DEFERRED_INIT call doesn't have a DECL_NAME. gcc/testsuite/ChangeLog: PR middle-end/107411 * g++.dg/pr107411.C: New test.=