public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "ian at airs dot com" <gcc-bugzilla@gcc.gnu.org> 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 [thread overview] Message-ID: <bug-110029-4@http.gcc.gnu.org/bugzilla/> (raw) https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110029 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 <stdio.h> 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 becomes a try/finally construct at the point of the variable declaration. But it does not obviously follow from the documentation. The documentation should be clear about this. Thanks.
next reply other threads:[~2023-05-29 21:25 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-05-29 21:25 ian at airs dot com [this message] 2023-05-29 21:37 ` [Bug c/110029] " pinskia at gcc dot gnu.org 2024-01-19 2:10 ` cvs-commit at gcc dot gnu.org 2024-01-19 2:12 ` sandra at gcc dot gnu.org 2024-01-19 17:55 ` ian at airs dot com 2024-01-20 17:23 ` pinskia at gcc dot gnu.org
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=bug-110029-4@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).