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

Bronek Kozicki brok at rubikon.pl
Fri Jan 21 07:39:03 EST 2005


From: "Terje Slettebø" <tslettebo at broadpark.no>
> 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

There's a bug in MSVC6 CRT - its implementation of "new" does not throw,
unless you use MFC. End even so, instead of std::bad_alloc you receive
CMemoryException (which does not inherit directly or indirectly from
std::exception). Ray Brown presented nice workaround for this bug :
http://www.codeguru.com/Cpp/Cpp/cpp_mfc/article.php/c793/


B.




More information about the Effective-cpp mailing list