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 via email to