This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Apply attribute returns_nonnull in libiberty


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]