This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

'new' behavior when malloc() fails


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]