public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "dhowells at redhat dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug tree-optimization/94527] New: RFE: Add an __attribute__ that marks a function as freeing an object
Date: Tue, 07 Apr 2020 22:44:29 +0000	[thread overview]
Message-ID: <bug-94527-4@http.gcc.gnu.org/bugzilla/> (raw)

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

            Bug ID: 94527
           Summary: RFE: Add an __attribute__ that marks a function as
                    freeing an object
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dhowells at redhat dot com
  Target Milestone: ---

Would it be possible to add a function attribute to indicate that the function
is going to destroy the object a the parameter points to (ie. a free()-like
function)?  Perhaps something like:

    void free(const volatile void *ptr) __attribute__((free(1)));

where the free(N) attribute indicates the parameter number[*].

[*] Note that it's possible that a free()-like function might also take
additional parameters to provide context and that context won't be destroyed.

The compiler could then warn upon future access through the pointer.

             reply	other threads:[~2020-04-07 22:44 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-07 22:44 dhowells at redhat dot com [this message]
2020-04-07 22:46 ` [Bug tree-optimization/94527] " dhowells at redhat dot com
2020-04-07 22:48 ` law at redhat dot com
2020-04-07 23:49 ` torvalds@linux-foundation.org
2020-04-08  0:18 ` law at redhat dot com
2020-04-08  0:48 ` torvalds@linux-foundation.org
2020-04-08  6:45 ` [Bug middle-end/94527] " rguenth at gcc dot gnu.org
2020-04-08  7:53 ` redi at gcc dot gnu.org
2020-04-08 16:28 ` msebor at gcc dot gnu.org
2020-04-08 16:44 ` torvalds@linux-foundation.org
2020-10-06 13:04 ` dmalcolm at gcc dot gnu.org
2020-10-27  1:28 ` msebor at gcc dot gnu.org
2020-11-13 21:47 ` msebor at gcc dot gnu.org
2020-11-13 21:57 ` msebor at gcc dot gnu.org
2020-12-03 22:43 ` cvs-commit at gcc dot gnu.org
2020-12-03 22:45 ` msebor 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-94527-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: link
Be 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).