From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 64A953857C40; Thu, 3 Aug 2023 16:11:46 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64A953857C40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691079106; bh=CbYeIMtvgqCMrdQCwJoR96PPeJ09t5yrDUpKjIoN8Po=; h=From:To:Subject:Date:In-Reply-To:References:From; b=JtWFwaA4CsIowuk2FDDwIC8LcTURnfZ9onVrU7dL4+yb4YuzG0tJTJ2hCJJsBi0/t a7Mf0tcdNkkzjaY2FQJ9E5OgKpuGJF9je+YeHX/26AfdmgHmVYSqRQSMd7a8JCyjPo FSw7r2aQ534O6OEcBcJL0F8Mlsh2aZ527pL1e9JU= From: "matz at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/110728] should __attribute__((cleanup())) callback get invoked for indirect edges of asm goto Date: Thu, 03 Aug 2023 16:11:45 +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: 14.0 X-Bugzilla-Keywords: EH, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: matz 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: 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D110728 --- Comment #11 from Michael Matz --- (In reply to Michael Matz from comment #9) > Just for completeness: I agree with Andrew that the initial code example = in > comment #0 doesn't show any problem. The edge from asmgoto to l0 doesn't > cross > the scope of the variable, hence no cleanups should be run. The cleanup > call that is there is from the edge that leaves the function scope before > return, and it's placed correctly. I was reminded that this is incorrect. Though it isn't documented that way (AFAICS) the cleanup attribute itself create a scope, as we're using the try/finally middle-end mechanisms to implement this attribute. We can't ch= ange that behaviour anymore of course, so that's how it has to be: jumping in fr= ont of the decl of 'x' _is_ supposed to run the cleanup. The initial example essentially boils down to: void test4(void) { l0:; try { /* implicit scope per instantiation of __cleanup__ variable */ int x __attribute__((cleanup(test4cleanup))); asm goto("# %l0"::::l0); /* <-- leaves scope created by x */ } finally { test4cleanup(); } }=