This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: malloc attributes and realloc
"Joseph S. Myers" <jsm@polyomino.org.uk> writes:
| The @code{malloc} attribute is used to tell the compiler that a function
| -may be treated as if it were the malloc function. The compiler assumes
| -that calls to malloc result in pointers that cannot alias anything.
| +may be treated as if any non-@code{NULL} pointer it returns cannot
| +alias any other pointer valid when the function returns.
| This will often improve optimization.
| +Standard functions with this property include @code{malloc},
| +@code{calloc} and @code{realloc}.
That is a clear improvement!
I think we'd better off not listing realloc for reasons exposed in
this thread.
-- Gaby