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

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,

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 1
Object deleted

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,


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 
M9F%L<V4[#0H-"F-L87-S($]B:B![#0IP=6)L:6,Z#0H)3V)J*"D >R!I9B`H
M9BD =&AR;W< ,3(S.R!]#0I].PT*#0I/8FHJ(&YO7W!T<CL-" T*=F]I9"!O
M<&5R871O<B!D96QE=&4H=F]I9"H <'1R*0T*>PT*"7!R:6YT9B B3V)J96-T
M(&1E;&5T961<;B(I.PT*?0T*#0II;G0 ;6%I;BAI;G0 87)G8RD-"GL-" EI
M9B`H87)G8R`^(#$I('L-" D)9B`]('1R=64[#0H)?0T*"6-H87( 8G5F9F5R
M6S P73L-" ET<GD >PT*"0EN;U]P='( /2!N97<H8G5F9F5R*2!/8FH[#0H)
M?2!C871C:"`H+BXN*2![#0H)"7!R:6YT9B B17AC97!T:6]N7&XB*3L-" E]
Sep 27 2005