From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 3303E3858413; Fri, 17 Sep 2021 01:43:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3303E3858413 From: "hv at crypt dot org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/102381] New: unexpected -Wmaybe-uninitialized Date: Fri, 17 Sep 2021 01:43:31 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 7.5.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: hv at crypt dot org 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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: Fri, 17 Sep 2021 01:43:31 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D102381 Bug ID: 102381 Summary: unexpected -Wmaybe-uninitialized Product: gcc Version: 7.5.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: hv at crypt dot org Target Milestone: --- This is reduced from perl source code. Reduction was a challenge, so there'= s a risk the essence may have been lost. The following code gives a -Wmaybe-uninitialized warning with each of "gcc-7 (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0", "gcc-9 (Ubuntu 9.2.1-17ubuntu1~18.04.= 1) 9.2.1 20191102" and self-built "gcc (GCC) 11.2.0". % cat test.c extern void fail(void) __attribute__((__noreturn__)); int** f(void); extern int *ip; extern int i2, i3;=20 void test(int i1) { int **ipp; if (i1) { ipp =3D f(); } for (int i4 =3D 0; i4 < i2; i4++) { if (((i3 & 1) !=3D 1) && ((i3 & 3) !=3D 3)) fail(); } if (i1) { ip =3D *ipp; } return; } % gcc -c -Wmaybe-uninitialized -O1 test.c test.c: In function 'test': test.c:18:14: warning: 'ipp' may be used uninitialized in this function [-Wmaybe-uninitialized] ip =3D *ipp; ^~~~ %=20 I think it should be clear that i1 does not change within this code, and the 'ip =3D *ipp' therefore cannot be reached without also previously having re= ached 'ipp =3D f()'. The sensitivity of the intervening code suggests this must b= e a bug, eg replacing 'if (((i3 & 1) !=3D 1) && ((i3 & 3) !=3D 3))' with 'if ((= i3 & 3) !=3D 3)' makes the warning disappear.=