[Exceptional C++ Style] Item 22: To new, Perchance to th

White Wolf wolof at freemail.hu
Fri Jan 21 09:50:46 EST 2005


Bronek Kozicki wrote:
> 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/

Just to be fair to Microsoft, they have never claimed they
do it right, so it is not a bug, but the system worked that
way by design. Introducing a new that throws (at that time)
would have caused way too much code to be broken, including
Microsoft's own. At least that is what I was told.

Attila




More information about the Effective-cpp mailing list