From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 966F1385840E; Mon, 29 May 2023 21:25:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 966F1385840E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685395550; bh=pZ+DacZigsFdzPI4UHjk098zRV2MGFL/byC3D0+F7kI=; h=From:To:Subject:Date:From; b=n8OTrhM4wKrGMoqKjZCpv/cnfYeScCwE+glmkSHrveCa3t8A94Wg4I1/H/ZLvmRlv RrJTGfJBCbiYTvt1Tc8v/6k0IS8G2zasHZbGyboEjLuL7Orqem6pjC0i7LwDbT4LQ7 TTSzo28XO6WBEOG8KhrsrfEZu8iPzKNs8bkJO0Ig= From: "ian at airs dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/110029] New: more precise documentation for cleanup attribute Date: Mon, 29 May 2023 21:25:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: ian at airs dot com X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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=3D110029 Bug ID: 110029 Summary: more precise documentation for cleanup attribute Product: gcc Version: 14.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: ian at airs dot com Target Milestone: --- The cleanup attribute is defined as running a function when a variable goes= out of scope. However, the documentation does not clearly say what happens when multiple variables are in scope. For example: #include static void adone (int *p __attribute__((unused))) { puts("adone"); } static void bdone (int *p __attribute__((unused))) { puts("bdone"); } void f () { int a __attribute__((cleanup (adone))); int b __attribute__((cleanup (bdone))); puts("f"); } int main() { f (); } With the current implementation, this prints f bdone adone This follows from the implementation, which is that a cleanup attribute bec= omes a try/finally construct at the point of the variable declaration. But it d= oes not obviously follow from the documentation. The documentation should be clear about this. Thanks.=