On Wed, Dec 04, 2013 at 03:57:43PM -0500, Jason Merrill wrote: > On 12/04/2013 03:21 PM, Oleg Endo wrote: > >Some days ago I've tried building an SH cross-GCC on OSX 10.9 with the > >latest XCode (clang) tools and its libc++ std lib. Some of the libc++ > >headers use malloc, realloc etc, which are poisoned in system.h. > > Well, presumably we are poisoning them because we don't want people > to use them. I don't remember why that was, and system.h doesn't > give a rationale, so I'm not sure if actual uses in the C++ library > are problematic.
I think the most important reason is that we want to handle out of mem cases consistently, so instead of malloc etc. we want users to use xmalloc etc. that guarantee non-NULL returned value, or fatal error and never returning. For operator new that is solvable through std::set_new_handler I guess, but for malloc we really don't want people to deal with checking NULL return values from those everywhere. Jakub