TITLE: failure behavior for "nothrow" new (Source: comp.lang.c++.moderated, 23 April 2001) LEE: "David M. Lee" > Should nothrow new call the new handler when memory is exhausted, > or does it just return 0? CLAMAGE: "Steve Clamage" If operator new cannot find memory and a new-handler is registered, operator new calls the new-handler, and again attempts to get more memory. If it can't get the memory and a new-handler is registered, it calls the new-handler, and again attempts to get more memory ... What you are missing is the requirement on a new-handler, which must do one of the following: - make more memory available - throw an exception of type std::bad_alloc (or of a derived type) - call abort() - call exit() Since your example new-handler does none of the above, your program goes into an infinite loop when no more dynamic memory is available. BTW, since a new-handler is allowed to exit via an exception, the nothrow version of operator new must catch any exception thrown by a new-handler, and return 0 to its caller. _______________________________________________ cpptips mailing list http://cpptips.hyperformix.com