* [libiberty] xmalloc cannot return NULL
@ 2013-10-14 17:59 Marc Glisse
2013-10-14 18:04 ` Mike Frysinger
0 siblings, 1 reply; 2+ messages in thread
From: Marc Glisse @ 2013-10-14 17:59 UTC (permalink / raw)
To: sid, newlib, gdb-patches, binutils, gcc-patches
Hello,
libiberty provides a function xmalloc that never returns NULL. However,
there are some hints that it might be ok if someone wants to supply their
own xmalloc that can return NULL (though that would break a lot of things,
including in libiberty itself).
I would like to remove that freedom, and the point of this email (I hope
it doesn't bounce from too many of these addresses) is to ask all
libiberty users if that would cause problems for them. I already heard
from gcc and gdb that they are happy forbidding a null return value from
xmalloc.
Why do I want to do that? I just added an attribute "returns_nonnull" to
gcc and would like to mark relevant functions, to let the compiler
optimize based on this property.
http://gcc.gnu.org/ml/gcc-patches/2013-10/msg00817.html
--
Marc Glisse
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [libiberty] xmalloc cannot return NULL
2013-10-14 17:59 [libiberty] xmalloc cannot return NULL Marc Glisse
@ 2013-10-14 18:04 ` Mike Frysinger
0 siblings, 0 replies; 2+ messages in thread
From: Mike Frysinger @ 2013-10-14 18:04 UTC (permalink / raw)
To: gdb-patches; +Cc: Marc Glisse, sid, newlib, binutils, gcc-patches
[-- Attachment #1: Type: Text/Plain, Size: 1086 bytes --]
On Monday 14 October 2013 13:59:16 Marc Glisse wrote:
> libiberty provides a function xmalloc that never returns NULL. However,
> there are some hints that it might be ok if someone wants to supply their
> own xmalloc that can return NULL (though that would break a lot of things,
> including in libiberty itself).
>
> I would like to remove that freedom, and the point of this email (I hope
> it doesn't bounce from too many of these addresses) is to ask all
> libiberty users if that would cause problems for them. I already heard
> from gcc and gdb that they are happy forbidding a null return value from
> xmalloc.
>
> Why do I want to do that? I just added an attribute "returns_nonnull" to
> gcc and would like to mark relevant functions, to let the compiler
> optimize based on this property.
>
> http://gcc.gnu.org/ml/gcc-patches/2013-10/msg00817.html
makes sense to me. as you point out, we write code based on the assumption
that NULL is never returned (although, perhaps phrased more accurately, that
the pointer returned is always valid).
-mike
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-10-14 18:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-14 17:59 [libiberty] xmalloc cannot return NULL Marc Glisse
2013-10-14 18:04 ` Mike Frysinger
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).