For Programmers: Free Programming Magazines  


Home > Archive > VC Language > May 2006 > Re: True/False: As of VC 6.0, with MS compilers, usage of new(noth









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: True/False: As of VC 6.0, with MS compilers, usage of new(noth
ultranet

2006-05-24, 7:10 pm

"Igor Tandetnik" wrote:

> "ultranet" <ultranet@discussions.microsoft.com> wrote in message
> news:EFDDFFE4-851F-4C80-9D77-7D64D809F9DA@microsoft.com
>
> False, as far as I can tell. Note that new(nothrow) does _not_ suppress
> an exception thrown from constructor. It only suppresses bad_alloc
> exception in case it fails to allocate memory.

I think the answer to my question is TRUE, because VC 6.0 and prior, for
instance, do not define:
placement operator delete(void *, std::nothrow_t const &).
along with
* All three forms of operator new[]
* All three forms of operator delete[]

Therefore, an exception in constructor doesn't resolve into a call to
operator delete(void *, std::nothrow_t const &)
which therefore leaves the memory unclaimed.

But you do have a point: if constructor throws, it appears there will be a
crash anyway, when using nothrow syntax, w/ no exception handler. And since
one has to use an try-catch for that sake, might as well using regular new
syntax.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com