From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A71D5385782B; Thu, 1 Apr 2021 22:32:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A71D5385782B From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/78993] [9/10/11 Regression] False positive from -Wmaybe-uninitialized Date: Thu, 01 Apr 2021 22:32: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: 7.0 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: P2 X-Bugzilla-Assigned-To: jeffreyalaw at gmail dot com X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cf_known_to_fail cf_reconfirmed_on short_desc 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 22:32:31 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D78993 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Known to fail|4.1.0, 5.3.0, 6.2.0, 7.0 |10.2.0, 11.0, 5.5.0, 6.4.0, | |7.2.0, 8.3.0, 9.1.0 Last reconfirmed|2017-01-05 00:00:00 |2021-4-1 Summary|False positive from |[9/10/11 Regression] False |-Wmaybe-uninitialized |positive from | |-Wmaybe-uninitialized --- Comment #7 from Martin Sebor --- Reconfirmed with GCC 11 as a regression introduced in r219703 (GCC 5.0). T= he warning for the smaller test case started with r147852 (GCC 4.5.0). (In reply to Manuel L=C3=B3pez-Ib=C3=A1=C3=B1ez from comment #5) > (In reply to Andrew Pinski from comment #4) > > # i_5 =3D PHI > > # j_27 =3D PHI > > # prephitmp_7 =3D PHI <0(3), prephitmp_17(4)> > > _14 =3D i_5 > 9; > > _18 =3D prephitmp_7 | _14; > > if (_18 !=3D 0) > > goto ; [44.99%] > > else > > goto ; [55.01%] > >=20 > >=20 > > Most likely conditional warning does not understand the above case :). >=20 > If the reason is the prephitmp_7 | _14, then this is PR42145 It doesn't understand it because it only deals with predicates of the form so when it sees (_18 !=3D 0)" and tries to com= pare it to another predicate it can only do it if the other one also involves _18 and that's not the case (there's only one _18 in the IL and that's this one= ). But I don't think it should matter in this case because it seems clear in t= he IL (as clear as anything can be) that j is undefined when (i < 0 && i > j) holds and used when (i >=3D 0 && i < j) holds, and those two are mutually exclusive. Yet when the warning logic tries to see if the predicate guardi= ng the definition of the variable is a superset of the one guarding its use is winds up looking at: def i_3(D) >=3D 0 && i_3(D) < j_6 (expanded) AND (NOT (i_3(D) < 0), NOT (i_3(D) >=3D j_6)) use (prephitmp_7 | i_5 > 9) =3D=3D 0 (expanded) NOT (_17 !=3D 0) Here's GCC 11 IL for the small test case: int foobar (int i) { int j; int i; int j; int _1; _Bool prephitmp_7; _Bool _16; _Bool _17; _Bool prephitmp_20; [local count: 1073741824]: # .MEM_9 =3D VDEF <.MEM_2(D)> j_6 =3D rand (); if (i_3(D) >=3D j_6) goto ; [55.78%] else goto ; [44.22%] [local count: 474808632]: if (i_3(D) < 0) goto ; [13.00%] else goto ; [87.00%] [local count: 413074919]: goto ; [100.00%] [local count: 61733713]: [local count: 273804168]: # j_26 =3D PHI # prephitmp_20 =3D PHI <0(9), 1(13)> # .MEM_10 =3D VDEF <.MEM_9> i_4 =3D rand (); [local count: 686879088]: # i_5 =3D PHI # .MEM_8 =3D PHI <.MEM_9(10), .MEM_10(4)> # j_27 =3D PHI # prephitmp_7 =3D PHI <0(10), prephitmp_20(4)> _16 =3D i_5 > 9; _17 =3D prephitmp_7 | _16; if (_17 !=3D 0) goto ; [0.00%] else goto ; [100.00%] [local count: 686879088]: goto ; [100.00%] [local count: 0]: [local count: 386862736]: # .MEM_11 =3D PHI <.MEM_8(11), .MEM_9(14)> [local count: 1073741824]: # _1 =3D PHI <0(6), j_27(12)> # .MEM_25 =3D PHI <.MEM_11(6), .MEM_8(12)> # VUSE <.MEM_25> return _1; [local count: 598933192]: if (i_3(D) < 0) goto ; [35.41%] else goto ; [64.59%] [local count: 386862736]: goto ; [100.00%] [local count: 212070456]: goto ; [100.00%] }=