From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 2CF0F3858421; Wed, 15 Dec 2021 18:43:32 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2CF0F3858421 From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/40635] bogus name and location in 'may be used uninitialized' warning Date: Wed, 15 Dec 2021 18:43:32 +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: 4.4.1 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: msebor at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.0 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, 15 Dec 2021 18:43:32 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D40635 --- Comment #16 from Martin Sebor --- With the patch in comment #13 committed in g:9695e1c23be5b5c55d572ced152897313ddb96ae GCC 12 prints the following for = the test case in comment #0: pr40635.c: In function =E2=80=98server_init=E2=80=99: pr40635.c:14:9: warning: =E2=80=98s42=E2=80=99 may be used uninitialized in= this function [-Wmaybe-uninitialized] 14 | int s42, x; | ^~~ But it doesn't show where the uninitialized variable is used. GCC 11 only points to the variable's use but doesn't say which variable it is: pr40635.c: In function =E2=80=98server_init=E2=80=99: pr40635.c:39:8: warning: =E2=80=98s42=E2=80=99 may be used uninitialized in= this function [-Wmaybe-uninitialized] 39 | if (sockt_rd < 0) | ^ So things have gotten both better and worse. The reason why the GCC 12 warning doesn't point to the use is because the u= se statement (_28 =3D _16 < 0; in basic block 8 below) has no location: [local count: 1073741824]: # _16 =3D PHI <[pr40635.c:22:20] -1(12), s42_9(7), [pr40635.c:29:16] -1(1= 4), s42_18(D)(11), s42_9(13)> [pr40635.c:38:5] foo (); _28 =3D _16 < 0; _5 =3D (int) _28; _4 =3D -_5; return _4; The location can still be found in the mergephi3 dump (pr40635.c.120t.mergephi3) and is gone from the phiopt2 dump (pr40635.c.121t.phiopt2): [local count: 5226752]: [local count: 1073741824]: # _16 =3D PHI <[../pr40635.c:22:20] -1(3), [../pr40635.c:30:12] s42_20(7), [../pr40635.c:29:16] -1(8)> [../pr40635.c:38:5] foo (); [../pr40635.c:39:8] if (_16 < 0) goto ; [0.73%] else goto ; [99.27%] [local count: 7838309]: [local count: 1073741824]: # _1 =3D PHI <[../pr40635.c:40:16] -1(10), [../pr40635.c:41:12] 0(9)> return _1; }=