[Exceptional C++ Style] Item 22: To new, Perchance to throw, Part 2: Pragmatic Issues in Memory Management

Terje Slettebø tslettebo at broadpark.no
Fri Jan 21 06:40:15 EST 2005


>From: "Paul Grenyer" <paul at paulgrenyer.co.uk>

> > Some systems may compile with exceptions disabled, and therefore can
only
> > safely use the nothrow version. No, that's not conformant, but, er,
that's
> > life, too.
>
> So what actually happens? Would you get a compile time error/warning as
you
> do with RTTI? Or a runtime error? Obviously there isn't going to be a
single
> answer to this, but what happens in the implementation you're thinking
> about?

I was thinking of MSVC. Interesting question; I tried to turn off exception
handling in MSVC, and use both throwing and non-throwing forms of new, and
there were no warnings or errors when compiling. However, it gave a warning
if you tried to use try-catch. Also, I tried to allocate ridiculous amounts
of memory, and saw then that when running the program, both forms of new
behaved the same way, in this configuration and on this platform - no
exception, just returning null.

Regards,

Terje





More information about the Effective-cpp mailing list