[Bug middle-end/94527] RFE: Add an __attribute__ that marks a function as freeing an object

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Apr 8 06:45:23 GMT 2020


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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |middle-end

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
Agreed that having an attribute to annotate free-like functions similar to how
we have one for malloc-like funtions would be nice.

How are semantics in the case such a function throws?  Or shall 'free' imply
nothrow and that it doesn't return abnormally (it doesn't call longjmp),
'leaf' would be a bit too strong but possibly easiest to require?

We could also simply say that the pointed to object is released (it's contents
become undefined) upon exiting the function by any means (normal return, EH
or abnormal).


More information about the Gcc-bugs mailing list