In almost every book about C++ I read, they
say that, if 'new' fails, it returnes a pointer to
NULL or they throw an exception (std:.bad_alloc).
Unfortunately, I compiled my application on a
outdated woody snapshot with gcc 2.95.3 and
I was not able to prevent my code from crashing.
When the system memory was exhausted, the
programm was aborted and a message 'out of
memory' appeared on the console.
I encapsulated the dangerous code in a 'try'
block and I catched 'std::bad_alloc' as well
as every other exception (catch(...)) but this
Testing the pointer if it is NULL didn't help
Is there a third way of what could happen
if 'new' fails? I only know the NULL- and the
On my machine at home (2.95.4, woody)
an exception is thrown and can be caugth.
But on that other woody machine, I couldn't
handle this situation.