public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/110029] New: more precise documentation for cleanup attribute
@ 2023-05-29 21:25 ian at airs dot com
  2023-05-29 21:37 ` [Bug c/110029] " pinskia at gcc dot gnu.org
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: ian at airs dot com @ 2023-05-29 21:25 UTC (permalink / raw)
  To: gcc-bugs

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.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/110029] more precise documentation for cleanup attribute
  2023-05-29 21:25 [Bug c/110029] New: more precise documentation for cleanup attribute ian at airs dot com
@ 2023-05-29 21:37 ` pinskia at gcc dot gnu.org
  2024-01-19  2:10 ` cvs-commit at gcc dot gnu.org
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2023-05-29 21:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110029

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2023-05-29
     Ever confirmed|0                           |1

--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
Yes it should mention last defined, first cleanup.

It does mention about the exception case.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/110029] more precise documentation for cleanup attribute
  2023-05-29 21:25 [Bug c/110029] New: more precise documentation for cleanup attribute ian at airs dot com
  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
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2024-01-19  2:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110029

--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Sandra Loosemore <sandra@gcc.gnu.org>:

https://gcc.gnu.org/g:ed28a835058d2e72036f4adb1dd60edf735c7d00

commit r14-8263-ged28a835058d2e72036f4adb1dd60edf735c7d00
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Fri Jan 19 02:06:55 2024 +0000

    More precise documentation for cleanup attribute [PR110029]

    gcc/ChangeLog
            PR c/110029
            * doc/extend.texi (Common Variable Attributes): Explain what
            happens when multiple variables with cleanups are in the same
scope.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/110029] more precise documentation for cleanup attribute
  2023-05-29 21:25 [Bug c/110029] New: more precise documentation for cleanup attribute ian at airs dot com
  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
  4 siblings, 0 replies; 6+ messages in thread
From: sandra at gcc dot gnu.org @ 2024-01-19  2:12 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110029

sandra at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |FIXED

--- Comment #3 from sandra at gcc dot gnu.org ---
Fixed.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/110029] more precise documentation for cleanup attribute
  2023-05-29 21:25 [Bug c/110029] New: more precise documentation for cleanup attribute ian at airs dot com
                   ` (2 preceding siblings ...)
  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
  4 siblings, 0 replies; 6+ messages in thread
From: ian at airs dot com @ 2024-01-19 17:55 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110029

--- Comment #4 from Ian Lance Taylor <ian at airs dot com> ---
Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c/110029] more precise documentation for cleanup attribute
  2023-05-29 21:25 [Bug c/110029] New: more precise documentation for cleanup attribute ian at airs dot com
                   ` (3 preceding siblings ...)
  2024-01-19 17:55 ` ian at airs dot com
@ 2024-01-20 17:23 ` pinskia at gcc dot gnu.org
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2024-01-20 17:23 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110029

Andrew Pinski <pinskia at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |14.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-01-20 17:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-29 21:25 [Bug c/110029] New: more precise documentation for cleanup attribute ian at airs dot com
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

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).