This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
'new' behavior when malloc() fails
- To: gcc-help at gcc dot gnu dot org
- Subject: 'new' behavior when malloc() fails
- From: David Whedon <dwhedon at gordian dot com>
- Date: Mon, 26 Feb 2001 23:17:37 -0800
I'm using the gnu c++ compiler. The question is related to the 'new' operator.
Sometimes the calls to __builtin_new (g++ generates these calls) return NULL
because there is no memory to be had (I'm working on an embedded system).
Unfortunately, the code that g++ generates doesn't check the return value of
__builtin_new before calling the class constructor.
I can only assume that this is by design.
Calling the constructor when the system was unable to allocate memory for the
class is bad? What am I missing?
This may be a c++ specific question, and may not be gcc-specific, if so I'm
happy to ask on a c++ list.
Thank you,
David Whedon