Home > Archive > VC Language > May 2006 > True/False: As of VC 6.0, with MS compilers, usage of new(nothrow)
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 |
True/False: As of VC 6.0, with MS compilers, usage of new(nothrow)
|
|
| ultranet 2006-05-23, 7:11 pm |
| results in a memory leak if the constuctor throws.
Also, is this true for VC 7.0, 7.1, and 2005?
Thaniks.
| |
| ultranet 2006-05-23, 7:11 pm |
|
"ultranet" wrote:
> results in a memory leak if the constuctor throws.
>
> Also, is this true for VC 7.0, 7.1, and 2005?
>
> Thaniks.
Also, i wasn't able to build new(nothrow) in an MFC project, but i was able
to use it in a Win32 project. Am i correct that MFC run-time library
disallows placement new and delete?
Thanks.
| |
| Igor Tandetnik 2006-05-23, 7:11 pm |
| "ultranet" <ultranet@discussions.microsoft.com> wrote in message
news:EFDDFFE4-851F-4C80-9D77-7D64D809F9DA@microsoft.com
> True/False: As of VC 6.0, with MS compilers, usage of new(nothrow)
> results in a memory leak if the constuctor throws.
> Also, is this true for VC 7.0, 7.1, and 2005?
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.
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
| |
| Igor Tandetnik 2006-05-23, 7:11 pm |
| "ultranet" <ultranet@discussions.microsoft.com> wrote in message
news:39D9E64E-BD75-4576-BCB3-FE011ED6A453@microsoft.com
> Also, i wasn't able to build new(nothrow) in an MFC project, but i
> was able to use it in a Win32 project. Am i correct that MFC run-time
> library disallows placement new and delete?
MFC defines 'new' as a macro, for debugging purposes. This macro
interferes with placement new syntax. Find and remove it from your
sources (it's typically defined at the top of every .cpp file).
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
| |
| Alex Blekhman 2006-05-24, 4:16 am |
| ultranet wrote:
> results in a memory leak if the constuctor throws.
>
> Also, is this true for VC 7.0, 7.1, and 2005?
The real question is: why do you need `new(nothrow)' at all?
What does it buy you to undergo all these troubles?
|
|
|
|
|