This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Apply attribute returns_nonnull in libiberty
- From: Jakub Jelinek <jakub at redhat dot com>
- To: DJ Delorie <dj at redhat dot com>
- Cc: Marc Glisse <marc dot glisse at inria dot fr>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 11 Oct 2013 20:38:29 +0200
- Subject: Re: Apply attribute returns_nonnull in libiberty
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 02 dot 1310111939180 dot 6899 at stedding dot saclay dot inria dot fr> <alpine dot DEB dot 2 dot 02 dot 1310111952490 dot 7051 at stedding dot saclay dot inria dot fr> <201310111830 dot r9BIUDTR021438 at greed dot delorie dot com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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