www.digitalmars.com         C & C++   DMDScript  

c++ - DMC 8.45 and new/delete

reply Wu Yongwei <Wu_member pathlink.com> writes:
Hi, Walter,

While I believe DMC has improved much in standard conformance, it is always weak
in new/delete.  I have not been to compile my memory leak detector
<URL:http://wyw.dcweb.cn/leakage.htm> under DMC because of this.  Specifically
it has the following problems:

1) Exception specification in operator new/delete results in an obscure message
like:

test.cpp(4) : Error: 'operator new' previously declared as something else
It was declared as: void *C func(unsigned )
It is now declared: void *C func(unsigned )

Even "throw()" cannot be used:

test.cpp(9) : Error: 'operator del' previously declared as something else
It was declared as: void C func(void *)
It is now declared: void C func(void *)

(And 'operator del' does not look better than 'operator delete'.)

2) Placement deallocation functions cannot be declared or defined:

test.cpp(9) : Error: must be void operator delete(void * [,size_t]);

3) `operator new' still defaults to the nothrow mode.  (Hey, old code should use
old compilers, or define their own global `operator new'.  Microsoft's `operator
new' does not throw in MSVC 6.0, but it does in MSVC 7.1.)

4) Use of new(nothrow) gives a strange error:

no_ptr = new(nothrow) Obj;
^
test.cpp(15) : Error: no match for function '?2(unsigned ,const std::nothrow_t)'

I really, really hope you can improve on this.

Best regards,

Yongwei
Sep 26 2005
next sibling parent "Walter Bright" <newshound digitalmars.com> writes:
All right, it's probably time to fix all that.
Sep 27 2005
prev sibling parent Wu Yongwei <Wu_member pathlink.com> writes:
C:\TEMP>test

C:\TEMP>test 1
Object deleted
Exception

The "Object deleted" message shows a problem: `operator delete' should not be
called in this case.  It is an old problem too.  This can really harm normal
program that can throw in constructors.

Best regards,

Yongwei


begin 0644 test.cpp
M(VEN8VQU9&4 /&-S=&1I;SX-"B-I;F-L=61E(#QC<W1D;&EB/ T*(VEN8VQU
M9&4 /&YE=SX-" T*=7-I;F< ;F%M97-P86-E('-T9#L-" T*8F]O;"!F(#T 


M<&5R871O<B!D96QE=&4H=F]I9"H <'1R*0T*>PT*"7!R:6YT9B B3V)J96-T





`
end
Sep 27 2005