Re: [libiberty] xmalloc cannot return NULL

Mike Frysinger <[email protected]> Mon, 14 Oct 2013 14:04:43 -0400
Newsgroups gmane.comp.emulators.sid.devel,gmane.comp.gdb.patches,gmane.comp.lib.newlib,gmane.comp.gnu.binutils,gmane.comp.gcc.patches
Message-ID <[email protected]>
--nextPart172744395.y0HCXvDVWQ
Content-Type: Text/Plain;
  charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

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).
>=20
> 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.
>=20
> 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.
>=20
> 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=
=20
that NULL is never returned (although, perhaps phrased more accurately, tha=
t=20
the pointer returned is always valid).
-mike

--nextPart172744395.y0HCXvDVWQ
Content-Type: application/pgp-signature; name=signature.asc 
Content-Description: This is a digitally signed message part.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iQIcBAABAgAGBQJSXDI9AAoJEEFjO5/oN/WB3dMP/iqmN5X09E+KsJNW3a/QVJdN
FvYpXpGq27ODYpFw1q1U3TxOveWNSsIl+lcHLh3Og+FYYj7jNPuUiZGGn65MoVJ9
AwoTffwD4kGpAJh93G/Zxfx9mXmPP97ogFuWFQiHTQZvWXNCKxSQ6+gh0/fUEo15
vZW1C2NDhtww5W4rbmR01G4fTKS2Br6z3zYd8tRs8XksT2HMDSXs6fVYuLy2Ymqo
bvoWYwRTkoIhYkAAGQwzpC5qtwByRzGumfci8kTnvIep6nRpf739i/uc8c7KJgFH
rN+ZsxiMTlZiuRjsP8h0gFrXnHpGNR2bKPil8KabpeqU7Jn9Ko/lw6Djc09wjBzP
dAfwiaAhsGONCeCO6U/xWkf8lcU1HhDZUlruaYTfbBSo8B9hAo/AL9VMJausxCOb
oN+a7Nmrs55FryJos/39PssPuWbc/SRtzCKH3ctPpa7sQYT7uk5dfuWqPjTZOUoD
aT7hpy5q/FvijpyT0ifHSEh2wU0HLNJxXsKev+lDP8tek4b73TYi7M9TMnCueqF8
GfJbFTbUWfeY0n0YKgqWD83Za+UrZtyh/5tRqce52e7Q60e0w5EebVgxmB24mNxS
YTWBGp8MeFty1a4rFlRz44AvwNGwOqaMCPcEcoqSgPtpNLr2Xf9vHocHqkKR/QaI
IoX6Dg/Oe+rUXF6P8hOG
=9Ly/
-----END PGP SIGNATURE-----

--nextPart172744395.y0HCXvDVWQ--