Apply attribute returns_nonnull in libiberty

Jakub Jelinek jakub@redhat.com
Fri Oct 11 18:43:00 GMT 2013


On Fri, Oct 11, 2013 at 02:30:13PM -0400, DJ Delorie wrote:
> 
> Your patch changes the rule that the application can override
> xmalloc() and get functions that return NULL...

Why would you want to do that?  Big part of libiberty itself
wouldn't allow such an implementation.
E.g. concat.c, argv.c, partition.c, xstrdup.c all dereference without
checking result of xmalloc.

In any case, if for some obscure reason we want to allow it for libiberty,
at least gcc itself certainly doesn't allow xmalloc etc. returning NULL,
so if you think it is wrong to put these into libiberty.h, we could
instead put those into gcc/system.h:
#if GCC_VERSION >= 4009
extern "C" {
__typeof (xmalloc) xmalloc ATTRIBUTE_RETURNS_NONNULL;
...
}
#endif

	Jakub



More information about the Gcc-patches mailing list