'new' behavior when malloc() fails

David Whedon dwhedon@gordian.com
Mon Feb 26 23:19:00 GMT 2001


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



More information about the Gcc-help mailing list