From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id EB003395249E; Wed, 20 Jan 2021 17:34:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org EB003395249E From: "msebor at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/98753] -Wfree-nonheap-object on unreachable code with -O0 Date: Wed, 20 Jan 2021 17:34:12 +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.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: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: short_desc cf_known_to_fail bug_status component 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, 20 Jan 2021 17:34:13 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98753 Martin Sebor changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|-Wfree-nonheap-object on |-Wfree-nonheap-object on |Bison generated code |unreachable code with -O0 Known to fail| |11.0 Status|WAITING |NEW Component|c++ |middle-end --- Comment #7 from Martin Sebor --- I can reproduce the warning with no optimization, thanks. At -O0, there are three calls to free in the IL when the warning runs. The second one that triggers it # .MEM_218 =3D VDEF <.MEM_216> free (yymsg.17_83); is eliminated by copy propagation at -O1. It's not eliminated at -O0 becau= se the optimization isn't done then. So the ultimate root cause of the proble= m is the same as in pr54202, except at -O0 (the test case there depends on inlining). It would be possible to disable the warning at -O0 to avoid this false posi= tive at the expense of some false negatives. I'm not sure that would be a good solution based on a single report. If more bugs like this are reported we might reconsider. Let me keep this bug open until then.=