------- Comment #2 from sebastian dot huber at embedded-brains dot de 2010-06-23 15:02 ------- (In reply to comment #1) > (In reply to comment #0) > > The std::bad_alloc definitions should be placed into a > > separate file. > > IIUC that wouldn't work, <new> is required to declare bad_alloc, so if > bad_alloc was moved to a separate file, the parts of the library which need > nothrow_t, new_handler and operator new etc. would still have to include > <new>, > which would still have to include bad_alloc. > > The way to achieve what you want is to put everything except bad_alloc in a > separate file, and include that file instead of <new> when bad_alloc is not > needed. >
There is nothing wrong with <new>. The problem is new_handler.cc. Suppose you use #include <new> int *p = new (std::nothrow) int; this will use the operator new implementation in new_opnt.cc. This one uses __new_handler which is now coupled with std::bad_alloc. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=44647