From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 32E093858D37; Tue, 26 Apr 2022 10:09:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32E093858D37 From: "rguenther at suse dot de" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/105346] [11/12 Regression] -Wno-free-nonheap-object false positive (on Bison-generated grammar code) Date: Tue, 26 Apr 2022 10:09:07 +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: 11.2.0 X-Bugzilla-Keywords: diagnostic X-Bugzilla-Severity: normal X-Bugzilla-Who: rguenther at suse dot de X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.4 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: Tue, 26 Apr 2022 10:09:07 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105346 --- Comment #9 from rguenther at suse dot de --- On Tue, 26 Apr 2022, jakub at gcc dot gnu.org wrote: > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105346 >=20 > --- Comment #8 from Jakub Jelinek --- > Started with r11-5732-gdce6c58db87ebf7f4477bd3126228e73e4eeee97 > The IL at -O0 -Wall looks during waccess pass like: > void foo () > { > char * bufp; > char buf[20]; >=20 > : > bufp_2 =3D &buf; > if (&buf !=3D bufp_2) > goto ; [INV] > else > goto ; [INV] >=20 > : > __builtin_free (bufp_2); >=20 > : > buf =3D{v} {CLOBBER(eol)}; > return; >=20 > } >=20 > So, I think the waccess pass must be walking SSA_NAME_DEF_STMT to figure = out it > is a free of non-heap. Either it shouldn't do that at -O0, or it should = only > walk them when they are in the same bb as the free call, or it needs to b= e able > to detect also conditionals like the above. It's using the ptr-query framework which discovers the bufp_2 equivalence but doesn't notice the conditional "invalidating" it.=