This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: g++: new that throw bad_alloc ?
- To: pkoning at xedia dot com (Paul Koning)
- Subject: Re: g++: new that throw bad_alloc ?
- From: Joe Buck <jbuck at synopsys dot com>
- Date: Mon, 13 Oct 97 9:37:41 PDT
- Cc: egcs at cygnus dot com (egcs team)
> I think I'd agree with the conclusion... but isn't the old-style
> behavior of new to return NULL?
The behavior of g++ 2.7.2.x is that NULL is never returned; rather,
you get a message "virtual memory exhausted" and the program exits.
It's possible to install a new_handler to get memory in some other
way.
That's why I said it's safe.
Code that wants to check the value of new needs to use the new nothrow
new (as specified in the CD2).