This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: malloc attributes and realloc
Gabriel Dos Reis <gdr@integrable-solutions.net> writes:
> I suggest we don't apply the malloc attribute to realloc -- but we
> correct (if possible) the comment in libiberty header.
It is perhaps worth noting that glibc does apply the malloc attribute
to realloc in <stdlib.h>.
If we are going to worry about xrealloc in libiberty.h, we should
certainly try to persuade glibc to change realloc in stdlib.h.
Although I initially believed otherwise, I now think that it is
possible to write a reasonable program which may be miscompiled if gcc
thinks that realloc has the malloc attribute. Whether such a program
actually exists in practice, I don't know. Whether such a program
strictly conforms to the C standard, I don't know.
Ian