From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 823243858D37; Tue, 26 Apr 2022 09:56:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 823243858D37 From: "jakub at gcc dot gnu.org" 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 09:56:06 +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: jakub at gcc dot gnu.org 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 09:56:06 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105346 --- 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]; : bufp_2 =3D &buf; if (&buf !=3D bufp_2) goto ; [INV] else goto ; [INV] : __builtin_free (bufp_2); : buf =3D{v} {CLOBBER(eol)}; return; } So, I think the waccess pass must be walking SSA_NAME_DEF_STMT to figure ou= t it is a free of non-heap. Either it shouldn't do that at -O0, or it should on= ly walk them when they are in the same bb as the free call, or it needs to be = able to detect also conditionals like the above.=